Esempio n. 1
0
 /**
  * handleAddChildToParent
  * Adds child node to parent node
  * @param addItemToCollectionCommand
  */
 public void handleAddChildToParent(Command addItemToCollectionCommand)
 {
     int parentId=addItemToCollectionCommand.getEntityId();
     int childId=addItemToCollectionCommand.getChildEntityId();
     byte[] arcName=addItemToCollectionCommand.getArcName();
     Node parent=registry.getNode(parentId);
     Arc oldArc = parent.getChildArc(arcName);
     Arc arc =registry.addChildToParent(parentId, childId,arcName);
     if(oldArc!=null){
     foreach (NodeModelChangedListener listenerNode in listenerNodes) {
         listenerNode.arcChanged(oldArc, arc);
     }
     }else{
     foreach (NodeModelChangedListener listenerNode in listenerNodes) {
         listenerNode.arcAdded(arc);
     }
     }
 }
Esempio n. 2
0
 /**
  * handleRemoveChildFromParent
  * Removes child node from parent node
  * @param removeItemFromCollectionCommand
  */
 public void handleRemoveChildFromParent(Command removeItemFromCollectionCommand)
 {
     int parentId=removeItemFromCollectionCommand.getEntityId();
     byte[] arcName = removeItemFromCollectionCommand.getArcName();
     Arc arc = registry.removeChildFromParent(parentId, arcName);
     foreach (NodeModelChangedListener listenerNode in listenerNodes) {
     listenerNode.arcRemoved(arc);
     }
 }
Esempio n. 3
0
 public Command revertCommand(Command command)
 {
     int commandType=command.getCommandType();
     Int32 entityId = command.getEntityId();
     Int32 childEntityId = command.getChildEntityId();
     Int32 schemaId=(Int32)command.GetSchemaId();
     Int32 coreManagerId=command.GetCoreManagerKey();
     Int32 sessionId=command.GetSessionId();
     bool lockEntity=command.getLock();
     bool oldLock=command.getOldLock();
     NodeAttribute[] oldAttributes=command.getOldAttributes();
     NodeAttribute[] attributes=command.getAttributes();
     byte[] arcName=command.getArcName();
     long lockTimeout=command.getLockTimeOut();
     switch (commandType){
         case PlanckDBConstants.CREATE_NEW_ENTITY:{
             return buildDeleteNode(entityId,lockEntity,schemaId,coreManagerId,sessionId, lockTimeout, attributes);
         }
         case PlanckDBConstants.DELETE_ENTITY:{
             Command newCommand= buildCreateNode(oldLock,schemaId,coreManagerId,sessionId, lockTimeout, oldAttributes);
             newCommand.Push(PlanckDBConstants.ENTITY_ID, PlanckDBConstants.INTEGER,entityId);
             return newCommand;
         }
         case PlanckDBConstants.ADD_CHILD_ENTITY_TO_PARENT_ENTITY:{
             return buildRemoveChildFromParentNode(entityId,arcName,childEntityId,schemaId,coreManagerId,sessionId, lockTimeout);
         }
         case PlanckDBConstants.REMOVE_CHILD_ENTITY_FROM_PARENT_ENTITY:{
             return buildAddChildToParentNode(entityId,childEntityId,arcName,schemaId,coreManagerId,sessionId, lockTimeout);
         }
         case PlanckDBConstants.UPDATE_ENTITY:{
             Command newCommand = buildUpdateNode(entityId, schemaId, coreManagerId, sessionId, lockTimeout, attributes);
             newCommand.Push(PlanckDBConstants.OLD_ATTRIBUTES, PlanckDBConstants.ATTRIBUTE_MAP,oldAttributes);
             return newCommand;
         }
         case PlanckDBConstants.ADD_ATTRIBUTE:{
             return buildRemoveAttributes(entityId,schemaId,coreManagerId,sessionId,lockTimeout,attributes);
         }
         case PlanckDBConstants.REMOVE_ATTRIBUTE:{
             return buildAddAttributes(entityId,schemaId,coreManagerId,sessionId, lockTimeout, oldAttributes);
         }
     }
     throw  new PlanckDBException("unsupported state the should not reach to this point of the code");
 }