Search in sources :

Example 1 with SubtreeHandler

use of org.brackit.xquery.node.parser.SubtreeHandler in project sirix by sirixdb.

the class DBCollection method add.

public DBNode add(final String resName, SubtreeParser parser) throws OperationNotSupportedException, DocumentException {
    try {
        final String resource = new StringBuilder(2).append("resource").append(mDatabase.listResources().size() + 1).toString();
        mDatabase.createResource(ResourceConfiguration.newBuilder(resource, mDatabase.getDatabaseConfig()).useDeweyIDs(true).useTextCompression(true).buildPathSummary(true).build());
        final ResourceManager manager = mDatabase.getResourceManager(ResourceManagerConfiguration.newBuilder(resource).build());
        final XdmNodeWriteTrx wtx = manager.beginNodeWriteTrx();
        final SubtreeHandler handler = new SubtreeBuilder(this, wtx, Insert.ASFIRSTCHILD, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList());
        // Make sure the CollectionParser is used.
        if (!(parser instanceof CollectionParser)) {
            parser = new CollectionParser(parser);
        }
        parser.parse(handler);
        return new DBNode(wtx, this);
    } catch (final SirixException e) {
        LOGGER.error(e.getMessage(), e);
        return null;
    }
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) CollectionParser(org.brackit.xquery.node.parser.CollectionParser) SubtreeHandler(org.brackit.xquery.node.parser.SubtreeHandler) SirixException(org.sirix.exception.SirixException) ResourceManager(org.sirix.api.ResourceManager)

Example 2 with SubtreeHandler

use of org.brackit.xquery.node.parser.SubtreeHandler in project sirix by sirixdb.

the class DBCollection method add.

@Override
public DBNode add(SubtreeParser parser) throws OperationNotSupportedException, DocumentException {
    try {
        final String resourceName = new StringBuilder(2).append("resource").append(mDatabase.listResources().size() + 1).toString();
        mDatabase.createResource(ResourceConfiguration.newBuilder(resourceName, mDatabase.getDatabaseConfig()).useDeweyIDs(true).useTextCompression(true).buildPathSummary(true).build());
        final ResourceManager resource = mDatabase.getResourceManager(ResourceManagerConfiguration.newBuilder(resourceName).build());
        final XdmNodeWriteTrx wtx = resource.beginNodeWriteTrx();
        final SubtreeHandler handler = new SubtreeBuilder(this, wtx, Insert.ASFIRSTCHILD, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList());
        // Make sure the CollectionParser is used.
        if (!(parser instanceof CollectionParser)) {
            parser = new CollectionParser(parser);
        }
        parser.parse(handler);
        return new DBNode(wtx, this);
    } catch (final SirixException e) {
        LOGGER.error(e.getMessage(), e);
        return null;
    }
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) CollectionParser(org.brackit.xquery.node.parser.CollectionParser) SubtreeHandler(org.brackit.xquery.node.parser.SubtreeHandler) SirixException(org.sirix.exception.SirixException) ResourceManager(org.sirix.api.ResourceManager)

Aggregations

CollectionParser (org.brackit.xquery.node.parser.CollectionParser)2 SubtreeHandler (org.brackit.xquery.node.parser.SubtreeHandler)2 ResourceManager (org.sirix.api.ResourceManager)2 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)2 SirixException (org.sirix.exception.SirixException)2