/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Pantheon.tech
* Modifications Copyright (C) 2022 Bell Canada
* ================================================================================
package org.onap.cps.spi;
+import java.io.Serializable;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.onap.cps.spi.model.DataNode;
void addListElements(String dataspaceName, String anchorName, String parentNodeXpath,
Collection<DataNode> listElementsCollection);
+ /**
+ * Add multiple lists of data nodes to a parent node at the same time.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @param parentNodeXpath parent node xpath
+ * @param newLists collections of lists of data nodes representing list elements
+ */
+ void addMultipleLists(String dataspaceName, String anchorName, String parentNodeXpath,
+ Collection<Collection<DataNode>> newLists);
+
/**
* Retrieves datanode by XPath for given dataspace and anchor.
*
DataNode getDataNode(String dataspaceName, String anchorName, String xpath,
FetchDescendantsOption fetchDescendantsOption);
-
/**
* Updates leaves for existing data node.
*
* @param xpath xpath
* @param leaves the leaves as a map where key is a leaf name and a value is a leaf value
*/
- void updateDataLeaves(String dataspaceName, String anchorName, String xpath, Map<String, Object> leaves);
+ void updateDataLeaves(String dataspaceName, String anchorName, String xpath, Map<String, Serializable> leaves);
/**
- * Replaces existing data node content including descendants.
+ * Replaces an existing data node's content including descendants.
*
* @param dataspaceName dataspace name
* @param anchorName anchor name
* @param dataNode data node
*/
- void replaceDataNodeTree(String dataspaceName, String anchorName, DataNode dataNode);
+ void updateDataNodeAndDescendants(String dataspaceName, String anchorName, DataNode dataNode);
+
+ /**
+ * Replaces multiple existing data nodes' content including descendants in a batch operation.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @param dataNodes data nodes
+ */
+ void updateDataNodesAndDescendants(String dataspaceName, String anchorName, final List<DataNode> dataNodes);
/**
* Replaces list content by removing all existing elements and inserting the given new elements
* included in the output
* @return the data nodes found i.e. 0 or more data nodes
*/
- Collection<DataNode> queryDataNodes(String dataspaceName, String anchorName,
- String cpsPath, FetchDescendantsOption fetchDescendantsOption);
+ List<DataNode> queryDataNodes(String dataspaceName, String anchorName,
+ String cpsPath, FetchDescendantsOption fetchDescendantsOption);
+ /**
+ * Starts a session which allows use of locks and batch interaction with the persistence service.
+ *
+ * @return Session ID string
+ */
+ String startSession();
+
+ /**
+ * Close session.
+ *
+ * @param sessionId session ID
+ */
+ void closeSession(String sessionId);
+
+ /**
+ * Lock anchor.
+ * To release locks(s), the session holding the lock(s) must be closed.
+ *
+ * @param sessionID session ID
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @param timeoutInMilliseconds lock attempt timeout in milliseconds
+ */
+ void lockAnchor(String sessionID, String dataspaceName, String anchorName, Long timeoutInMilliseconds);
}