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 class
IndexingCommand.Type
-
Field Summary
Fields Modifier and Type Field Description protected String
id
protected long
order
protected String
path
static String
PREFIX
protected boolean
recurse
protected String
repositoryName
protected List<String>
schemas
protected static AtomicLong
seq
protected boolean
sync
protected String
targetDocumentId
protected IndexingCommand.Type
type
-
Constructor Summary
Constructors Modifier Constructor Description protected
IndexingCommand()
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 void
addSchemas(String schema)
void
attach(CoreSession session)
protected boolean
canBeMerged(IndexingCommand other)
IndexingCommand
clone(DocumentModel newDoc)
static IndexingCommand
fromJSON(com.fasterxml.jackson.databind.JsonNode jsonNode)
static IndexingCommand
fromJSON(String json)
Create a command from a JSON string.String
getId()
long
getOrder()
String
getRepositoryName()
String[]
getSchemas()
DocumentModel
getTargetDocument()
Return the document or null if it does not exists anymore.String
getTargetDocumentId()
IndexingCommand.Type
getType()
protected DocumentModel
getValidTargetDocument(DocumentModel target)
boolean
isRecurse()
boolean
isSync()
void
makeSync()
Try to make the command synchronous.protected void
merge(boolean sync, boolean recurse)
boolean
merge(IndexingCommand other)
void
setOrder(long order)
String
toJSON()
void
toJSON(com.fasterxml.jackson.core.JsonGenerator jsonGen)
String
toString()
-
-
-
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)
-
-