Exemplo n.º 1
0
 /**
      * Adds attributes to node.<p>
      * If one or more attributes with the same name exists
      * the old attribute/s with the same name will be override.
      * @param entityId
      * @param attributes
      */
 public void addAttributes(int entityId, NodeAttribute[] attributes)
 {
     try{
             reentrantLock.enter();
             Node node=getNode(entityId);
             ByteArrayToAttributeyMap nodeAttributes = node.getAttributes();
             foreach (NodeAttribute attribute in attributes) {
                 nodeAttributes.put(attribute.getName(),attribute);
             }
         }finally {
             reentrantLock.exit();
         }
 }
Exemplo n.º 2
0
 /**
  * addAttribute method;
  * Add attribute
  * using this method ensure that the server has have accepted
  * the attribute addition, and it also ensure that all the clients will
  * receive the change by the same sequence in which the server has.
  * But it is impossible predict the change acceptance time in the remote
  * clients because of networks limits.
  * @param node
  * @param attributes
  * @throws AbstractPlanckDBException
  */
 public void AddAttributes(Node node, NodeAttribute[] attributes)
 {
     List<NodeAttribute> values = node.getAttributes().values();
     NodeAttribute[] oldAttributes = values.ToArray();
     Command command = commandBuilder.buildAddAttributes(node.getId(), sessionMetaData.getSchemaId(), core.getCoreManager().getKey(), sessionMetaData.GetSessionId(), lockTimeout ,attributes);
     command.Push(PlanckDBConstants.OLD_ATTRIBUTES,PlanckDBConstants.ATTRIBUTE_MAP,oldAttributes);
     commandExecutor.produce(command);
 }
Exemplo n.º 3
0
 /**
  * createNode method:
  * Creates new node:
  * Creating node by this method ensure that the server has have accepted
  * the node creation, and it also ensure that all the clients will
  * receive the change by the same sequence in which the server has received.
  * But it is impossible predict the change acceptance time in the remote
  * clients because of networks limits.
  * @param attributes
  * @return
  * @throws PlanckDBException
  * @throws TransactionException
  */
 public Node CreateNode(NodeAttribute[]attributes)
 {
     Command command = commandBuilder.buildCreateNode(false, sessionMetaData.getSchemaId(), core.getCoreManager().getKey(), sessionMetaData.GetSessionId(),  lockTimeout,attributes);
     commandExecutor.produce(command);
     Int32 entityId = command.getEntityId();
     return registry.getNode(entityId);
 }
Exemplo n.º 4
0
        /**
             * Clear the attributes container ans sets new attributes<p>
             * return all the attributes which name doesn't exit in the new attributes list ( removed attributes ).
             *
             * @param entityId
             * @param attributesArray
             * @return
             */
        public List<NodeAttribute> updateNode(int entityId, NodeAttribute[] attributesArray)
        {
            List<NodeAttribute> removed=new List<NodeAttribute>();
                try{
                    reentrantLock.enter();
                    Node node=getNode(entityId);
                     foreach (NodeAttribute oldAttribute in node.getAttributes().values()) {
                        bool found=false;
                        foreach (NodeAttribute newAttribute in attributesArray) {
                            if(Arrays.equals(oldAttribute.getName(),newAttribute.getName())){
                                found=true;
                                break;
                            }
                        }
                        if(! found){
                            node.getAttributes().remove(oldAttribute.getName());
                            removed.Add(oldAttribute);
                        }
                    }
                    foreach (NodeAttribute attribute in attributesArray) {
                        node.getAttributes().put(attribute.getName(),attribute);
                    }

                }finally {
                    reentrantLock.exit();
                }
                return removed;
        }
Exemplo n.º 5
0
 /**
      * Create new node.
      * @param entityId
      * @param lock
      * @param sessionId
      * @param ownerId
      * @param attributes
      * @return
      */
 public Node createNewNode(int entityId, bool lockEntity,int sessionId,int ownerId,NodeAttribute[]attributes)
 {
     try{
             reentrantLock.enter();
             Node node=new Node(entityId, lockEntity,sessionId,ownerId,attributes);
             idMap[entityId]=node;
             return node;
         }finally {
             reentrantLock.exit();
         }
 }
Exemplo n.º 6
0
 public NodeAttribute put(byte[] name, NodeAttribute attribute)
 {
     return map[new ByteArrayWrapper(name)] = attribute;
 }
Exemplo n.º 7
0
 public bool containsValue(NodeAttribute attribute)
 {
     return map.ContainsValue(attribute);
 }