Package org.nuxeo.elasticsearch.commands
Class IndexingCommand
- java.lang.Object
-
- org.nuxeo.elasticsearch.commands.IndexingCommand
-
- All Implemented Interfaces:
Serializable
public class IndexingCommand extends Object implements Serializable
Holds information about what type of indexing operation must be processed. IndexingCommands are create "on the fly" via a Synchronous event listener and at post commit time the system will merge the commands and execute worker to process them.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexingCommand.Type
-
Field Summary
Fields Modifier and Type Field Description protected Stringidprotected longorderprotected Stringpathstatic StringPREFIXprotected booleanrecurseprotected StringrepositoryNameprotected List<String>schemasprotected static AtomicLongseqprotected booleansyncprotected StringtargetDocumentIdprotected IndexingCommand.Typetype
-
Constructor Summary
Constructors Modifier Constructor Description protectedIndexingCommand()IndexingCommand(DocumentModel document, IndexingCommand.Type commandType, boolean sync, boolean recurse)Create an indexing command
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSchemas(String schema)voidattach(CoreSession session)protected booleancanBeMerged(IndexingCommand other)IndexingCommandclone(DocumentModel newDoc)static IndexingCommandfromJSON(com.fasterxml.jackson.databind.JsonNode jsonNode)static IndexingCommandfromJSON(String json)Create a command from a JSON string.StringgetId()longgetOrder()StringgetRepositoryName()String[]getSchemas()DocumentModelgetTargetDocument()Return the document or null if it does not exists anymore.StringgetTargetDocumentId()IndexingCommand.TypegetType()protected DocumentModelgetValidTargetDocument(DocumentModel target)booleanisRecurse()booleanisSync()voidmakeSync()Try to make the command synchronous.protected voidmerge(boolean sync, boolean recurse)booleanmerge(IndexingCommand other)voidsetOrder(long order)StringtoJSON()voidtoJSON(com.fasterxml.jackson.core.JsonGenerator jsonGen)StringtoString()
-
-
-
Field Detail
-
PREFIX
public static final String PREFIX
- See Also:
- Constant Field Values
-
id
protected String id
-
type
protected IndexingCommand.Type type
-
sync
protected boolean sync
-
recurse
protected boolean recurse
-
targetDocumentId
protected String targetDocumentId
-
path
protected String path
-
repositoryName
protected String repositoryName
-
order
protected long order
-
seq
protected static transient AtomicLong seq
-
-
Constructor Detail
-
IndexingCommand
protected IndexingCommand()
-
IndexingCommand
public IndexingCommand(DocumentModel document, IndexingCommand.Type commandType, boolean sync, boolean recurse)
Create an indexing command- Parameters:
document- the target documentcommandType- the type of commandsync- if true the command will be processed on the same thread after transaction completion and the Elasticsearch index will be refreshrecurse- the command affect the document and all its descendants
-
-
Method Detail
-
getValidTargetDocument
protected DocumentModel getValidTargetDocument(DocumentModel target)
-
attach
public void attach(CoreSession session)
-
getTargetDocument
public DocumentModel getTargetDocument()
Return the document or null if it does not exists anymore.- Throws:
IllegalStateException- if there is no session attached
-
getRepositoryName
public String getRepositoryName()
-
merge
public boolean merge(IndexingCommand other)
- Returns:
- true if merged
-
merge
protected void merge(boolean sync, boolean recurse)
-
canBeMerged
protected boolean canBeMerged(IndexingCommand other)
-
isSync
public boolean isSync()
-
isRecurse
public boolean isRecurse()
-
getType
public IndexingCommand.Type getType()
-
toJSON
public String toJSON() throws IOException
- Throws:
IOException
-
toJSON
public void toJSON(com.fasterxml.jackson.core.JsonGenerator jsonGen) throws IOException- Throws:
IOException
-
fromJSON
public static IndexingCommand fromJSON(String json)
Create a command from a JSON string.- Throws:
IllegalArgumentException- if json is invalid or command is invalid
-
fromJSON
public static IndexingCommand fromJSON(com.fasterxml.jackson.databind.JsonNode jsonNode)
-
getId
public String getId()
-
getTargetDocumentId
public String getTargetDocumentId()
-
clone
public IndexingCommand clone(DocumentModel newDoc)
-
getSchemas
public String[] getSchemas()
-
addSchemas
public void addSchemas(String schema)
-
makeSync
public void makeSync()
Try to make the command synchronous. Recurse command will stay in async for update.
-
getOrder
public long getOrder()
-
setOrder
public void setOrder(long order)
-
-