Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.EditableDocument


        // Modify using an editor ...
        try {
            tm.begin();
            db.lock(key);
            EditableDocument editable = db.editContent(key, true);
            editable.setBoolean("k3", true);
            editable.setNumber("k4", 3.5d);
        } finally {
            tm.commit();
        }

        // Now re-read ...
View Full Code Here


        }
    }

    private void addChildren( String parentKey, Iterable<Document> children ) throws Exception {
        tm.begin();
        EditableDocument parent = db.editContent(parentKey, false);
        EditableArray childrenArray = parent.getOrCreateArray("children");
        for (Document child : children) {
            String childName = child.getDocument(SchematicEntry.FieldName.CONTENT).getString("name");
            String childId = child.getDocument(SchematicEntry.FieldName.METADATA).getString(SchematicEntry.FieldName.ID);
            childrenArray.add(Schematic.newDocument("childId", childId, "childName", childName));
View Full Code Here

        if (other == this) return;
        for (Field field : other.fields()) {
            Document otherDoc = field.getValueAsDocument();
            if (!Null.matches(otherDoc)) {
                // Get the corresponding value in this document ...
                EditableDocument thisField = getDocument(field.getName());
                if (!Null.matches(thisField)) {
                    // There are docs in both sides, so merge them ...
                    thisField.merge(otherDoc);
                } else {
                    // There is not a document on this side (perhaps another value), so replace with that other doc ...
                    doSetValue(field.getName(), otherDoc);
                }
            } else {
View Full Code Here

    public SchematicEntry storeDocument( String key,
                                         Document document ) {
        Connector connector = connectors.getConnectorForSourceKey(sourceKey(key));
        if (connector != null) {
            checkConnectorIsWritable(connector);
            EditableDocument editableDocument = replaceNodeKeysWithDocumentIds(document);
            connector.storeDocument(editableDocument);
        }
        return null;
    }
View Full Code Here

    @Override
    public void updateDocument(String key, Document document,  SessionNode sessionNode) {
        Connector connector = connectors.getConnectorForSourceKey(sourceKey(key));
        if (connector != null) {
            checkConnectorIsWritable(connector);
            EditableDocument editableDocument = replaceNodeKeysWithDocumentIds(document);
            String documentId = documentIdFromNodeKey(key);
            MutableCachedNode.NodeChanges nodeChanges = sessionNode.getNodeChanges();
            DocumentChanges documentChanges = createDocumentChanges(nodeChanges,
                    connector.getSourceName(),
                    editableDocument,
View Full Code Here

        if (connector != null) {
            String docId = documentIdFromNodeKey(key);
            Document document = connector.getDocumentById(docId);
            if (document != null) {
                // clone the document, so we don't alter the original
                EditableDocument editableDocument = replaceConnectorIdsWithNodeKeys(document, connector.getSourceName());
                editableDocument = updateCachingTtl(connector, editableDocument);
                editableDocument = updateQueryable(connector, editableDocument);

                // Extract any embedded documents ...
                editableDocument.remove(DocumentTranslator.EMBEDDED_DOCUMENTS);
                return new FederatedSchematicEntry(editableDocument);
            }
        }
        return null;
    }
View Full Code Here

            String parentKey = documentIdToNodeKeyString(sourceName, parentId);
            parentKeys.add(parentKey);
        }

        // replace the id of each block (if they exist)
        EditableDocument childrenInfo = writer.document().getDocument(DocumentTranslator.CHILDREN_INFO);
        if (childrenInfo != null) {
            String nextBlockKey = childrenInfo.getString(DocumentTranslator.NEXT_BLOCK);
            if (!StringUtil.isBlank(nextBlockKey)) {
                childrenInfo.setString(DocumentTranslator.NEXT_BLOCK, documentIdToNodeKeyString(sourceName, nextBlockKey));
            }
            String lastBlockKey = childrenInfo.getString(DocumentTranslator.LAST_BLOCK);
            if (!StringUtil.isBlank(lastBlockKey)) {
                childrenInfo.setString(DocumentTranslator.LAST_BLOCK, documentIdToNodeKeyString(sourceName, lastBlockKey));
            }
        }
        // create the federated node key - external project back reference
        if (externalDocumentKey != null) {
            String projectedNodeKey = connectors.getProjectedNodeKey(externalDocumentKey);
            if (!StringUtil.isBlank(projectedNodeKey)) {
                parentKeys.add(projectedNodeKey);
            }
        }
        writer.setParents(parentKeys);

        // process each child in the same way
        List<Document> updatedChildren = new ArrayList<Document>();
        for (Document child : reader.getChildren()) {
            EditableDocument childWithReplacedIds = replaceConnectorIdsWithNodeKeys(child, sourceName);
            updatedChildren.add(childWithReplacedIds);
        }
        writer.setChildren(updatedChildren);

        // process the properties to look for **INTERNAL** references ...
View Full Code Here

        writer.setParents(parentIds);

        // process each child in the same way
        List<Document> updatedChildren = new ArrayList<Document>();
        for (Document child : reader.getChildren()) {
            EditableDocument childWithReplacedIds = replaceNodeKeysWithDocumentIds(child);
            updatedChildren.add(childWithReplacedIds);
        }
        writer.setChildren(updatedChildren);

        return writer.document();
View Full Code Here

        // Modify using an editor ...
        try {
            tm.begin();
            db.lock(key);
            EditableDocument editable = db.editContent(key, true);
            editable.setBoolean("k3", true);
            editable.setNumber("k4", 3.5d);
        } finally {
            tm.commit();
        }

        // Now re-read ...
View Full Code Here

        // Modify using an editor ...
        try {
            tm.begin();
            db.lock(key);
            EditableDocument editable = db.editContent(key, true);
            editable.setBoolean("k3", true);
            editable.setNumber("k4", 3.5d);
        } finally {
            tm.commit();
        }

        // Now re-read ...
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.EditableDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.