Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.EditableDocument


        @Override
        public void storeProperties( String id,
                                     Map<Name, Property> properties ) {
            String key = keyFor(id);
            EditableDocument doc = Schematic.newDocument();
            for (Map.Entry<Name, Property> entry : properties.entrySet()) {
                Property property = entry.getValue();
                if (property != null) {
                    translator.setProperty(doc, property, null, null);
                }
View Full Code Here


        @Override
        public void updateProperties( String id,
                                      Map<Name, Property> properties ) {
            String key = keyFor(id);
            EditableDocument doc = localStore.edit(key, true);
            assert doc != null;
            for (Map.Entry<Name, Property> propertyEntry : properties.entrySet()) {
                Property property = propertyEntry.getValue();
                if (property != null) {
                    translator.setProperty(doc, property, null, null);
View Full Code Here

        final AddressContext addressContext = AddressContext.forOperation(operation);
        final String repositoryName = addressContext.repositoryName();

        // Build the 'binaryStorage' document ...
        EditableDocument binaries = Schematic.newDocument();

        writeCommonBinaryStorageConfiguration(context, model, binaries);
        writeBinaryStorageConfiguration(repositoryName, context, model, binaries);

        //the store-name attribute is specific only to nested stores, as per schema
        final boolean isNestedStore = model.hasDefined(ModelKeys.STORE_NAME);
        ServiceName serviceName = ModeShapeServiceNames.binaryStorageDefaultServiceName(repositoryName);
        if (isNestedStore) {
            //if it's part of a composite binary container, we don't want to overwrite the default binary service because
            //the composite binary storage container will do that
            String binaryStorageName = binaries.getString(FieldName.BINARY_STORE_NAME);
            assert binaryStorageName != null;
            serviceName = ModeShapeServiceNames.binaryStorageNestedServiceName(repositoryName, binaryStorageName);
        } else {
            // Remove the default service, added by "AddRepository"
            context.removeService(serviceName);
View Full Code Here

            return localStore().putIfAbsent(key, 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

            localStore().updateDocument(key, document, null);
        } else {
            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,
                                                                        documentId);
                connector.updateDocument(documentChanges);
View Full Code Here

                String docId = documentIdFromNodeKey(key);
                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 ...
                Object removedContainer = editableDocument.remove(DocumentTranslator.EMBEDDED_DOCUMENTS);
                if (removedContainer instanceof EditableDocument) {
                    EditableDocument embeddedDocs = (EditableDocument)removedContainer;
                    for (Document.Field field : embeddedDocs.fields()) {
                        String id = field.getName();
                        Document doc = field.getValueAsDocument();
                        // Place the embedded document in the local value store ...
                        if (doc != null) localStore().put(id, doc);
                    }
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

        return nestedStoresValues.get(storeName);
    }

    @Override
    public void start( StartContext startContext ) {
        EditableDocument compositeDocument = Schematic.newDocument();
        //iterate through all the contained nested stored values (which should've been started) and update this configuration
        for (String storeName : nestedStoresValues.keySet()) {
            compositeDocument.set(storeName, nestedStoresValues.get(storeName).getValue().getBinaryConfiguration());
        }
        binaries.setDocument(RepositoryConfiguration.FieldName.COMPOSITE_STORE_NAMED_BINARY_STORES, compositeDocument);
    }
View Full Code Here

            assert binaryStorageConfig != null;
            Document binaryConfig = binaryStorageConfig.getBinaryConfiguration();
            assert binaryConfig != null;

            // Create a new configuration document ...
            EditableDocument config = Schematic.newDocument(repositoryConfiguration.getDocument());

            config.getOrCreateDocument(FieldName.STORAGE).setDocument(FieldName.BINARY_STORAGE, binaryConfig);

            if (config.containsField(FieldName.JOURNALING)) {
                if (StringUtil.isBlank(this.journalRelativeTo)) {
                    this.journalRelativeTo = getDataDirectoryPathInjector().getValue();
                }
                if (StringUtil.isBlank(this.journalPath)) {
                    this.journalPath = "journal";
                }
                String finalJournalLocation = this.journalRelativeTo + "/" + this.journalPath;
                config.getDocument(FieldName.JOURNALING).setString(FieldName.JOURNAL_LOCATION, finalJournalLocation);
            }

            if (LOG.isDebugEnabled()) {
                LOG.debugv("ModeShape configuration for '{0}' repository: {1}", repositoryName, config);
                Problems problems = repositoryConfiguration.validate();
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.