Package org.lilyproject.tools.import_.json

Examples of org.lilyproject.tools.import_.json.WriteOptions


    private void loadConfig(InputStream is)
            throws IOException, JsonFormatException, RepositoryException, ImportConflictException,
            ImportException, InterruptedException, SecurityException, IllegalArgumentException, NoSuchMethodException,
            InstantiationException, IllegalAccessException, InvocationTargetException {

        jsonImport = new JsonImport(table, repository, new DefaultImportListener());
        JsonParser jp = JsonFormat.JSON_FACTORY_NON_STD.createJsonParser(is);

        JsonToken current;
        current = jp.nextToken();
View Full Code Here


    }

    private void createSchema(JsonNode configNode) throws IOException, RepositoryException, ImportConflictException,
            ImportException, JsonFormatException, NoServersException, InterruptedException, KeeperException {

        JsonImport jsonImport = new JsonImport(table, repository, new DefaultImportListener());

        // Namespaces
        ObjectNode namespacesNode = JsonUtil.getObject(configNode, "namespaces", null);
        if (namespacesNode != null) {
            jsonImport.readNamespaces(namespacesNode);
View Full Code Here

    private void loadConfig(InputStream is)
            throws IOException, JsonFormatException, RepositoryException, ImportConflictException,
            ImportException, InterruptedException, SecurityException, IllegalArgumentException, NoSuchMethodException,
            InstantiationException, IllegalAccessException, InvocationTargetException {

        jsonImport = new JsonImport(table, repository, new DefaultImportListener());
        JsonParser jp = JsonFormat.JSON_FACTORY_NON_STD.createJsonParser(is);

        JsonToken current;
        current = jp.nextToken();
View Full Code Here

    }

    private void createSchema(JsonNode configNode) throws IOException, RepositoryException, ImportConflictException,
            ImportException, JsonFormatException, NoServersException, InterruptedException, KeeperException {

        JsonImport jsonImport = new JsonImport(table, repository, new DefaultImportListener());

        // Namespaces
        ObjectNode namespacesNode = JsonUtil.getObject(configNode, "namespaces", null);
        if (namespacesNode != null) {
            jsonImport.readNamespaces(namespacesNode);
        }

        // Fields
        JsonNode fieldTypesNode = configNode.get("fieldTypes");
        if (fieldTypesNode != null && fieldTypesNode.isArray()) {
            for (JsonNode fieldTypeNode : fieldTypesNode) {
                FieldType importFieldType = jsonImport.importFieldType(fieldTypeNode);
                JsonNode propertiesNode = fieldTypeNode.get("properties");

                fieldTypes.put(importFieldType.getName(),
                        new TestFieldType(importFieldType, table, repository, propertiesNode));
            }
        }

        // Record type
        JsonNode recordTypesNode = configNode.get("recordTypes");
        if (recordTypesNode != null && recordTypesNode.isArray()) {
            for (JsonNode recordTypeNode : recordTypesNode) {
                String recordTypeName = JsonUtil.getString(recordTypeNode, "name");
                QName recordTypeQName = QNameConverter.fromJson(recordTypeName, jsonImport.getNamespaces());
                recordType = repository.getTypeManager().newRecordType(recordTypeQName);
                TestRecordType testRecordType = new TestRecordType();
                // Fields
                for (JsonNode fieldNode : recordTypeNode.get("fields")) {
                    String fieldName = JsonUtil.getString(fieldNode, "name");
View Full Code Here

    }

    @Test
    public void testLineBasedJsonImport() throws Exception {
        JsonImport.loadJsonLines(table, repository,
                getClass().getResourceAsStream("json_line_input.txt"), new ImportSettings());

        Record record = table.read(repository.getIdGenerator().fromString("USER.jsonline1"));
        assertEquals("hello1", record.getField(new QName("ns", "stringField")));

        record = table.read(repository.getIdGenerator().fromString("USER.jsonline2"));
View Full Code Here

        assertEquals("hello2", record.getField(new QName("ns", "stringField")));
    }

    @Test
    public void testIgnoreEmptyFields() throws Exception {
        ImportSettings settings = new ImportSettings();
        settings.recordReader = IgnoreAndDeleteEmptyFieldsRecordReader.INSTANCE;
        JsonImport.load(table, repository, getClass().getResourceAsStream("emptyfieldsignore_1.json"), settings);

        QName stringField = new QName("ns", "string");
        QName integerField = new QName("ns", "integer");
View Full Code Here

        if (recordType.getName() == null) {
            throw new ImportException("Missing name property on record type.");
        }

        ImportMode mode = getImportMode(node, ImportMode.CREATE_OR_UPDATE);

        ImportResult<RecordType> result = RecordTypeImport.importRecordType(recordType, mode,
                IdentificationMode.NAME, recordType.getName(), true, repository.getTypeManager());
        RecordType newRecordType = result.getEntity();
View Full Code Here

            throw new ImportException("Record should be specified as object node.");
        }

        Record record = recordReader.fromJson(node, namespaces, repository);

        ImportMode mode = getImportMode(node, ImportMode.CREATE_OR_UPDATE);

        if (mode == ImportMode.UPDATE && record.getId() == null) {
            throw new ImportException(String.format("Import mode %s is specified but the record has no id.",
                    ImportMode.UPDATE));
        }
View Full Code Here

        // TODO record we respond with should be full record or be limited to user-specified field list
        record = result.getEntity();
        Response response;

        ImportResultType resultType = result.getResultType();
        switch (resultType) {
            case CREATED:
                URI uri = uriInfo.getBaseUriBuilder().path(RecordResource.class).build(record.getId());
                response = Response.created(uri).entity(Entity.create(record, uriInfo)).build();
                break;
View Full Code Here

            // TODO record we respond with should be full record or be limited to user-specified field list
            record = result.getEntity();
            Response response;

            ImportResultType resultType = result.getResultType();
            switch (resultType) {
                case CANNOT_UPDATE_DOES_NOT_EXIST:
                    throw new ResourceException("Record not found: " + recordId, NOT_FOUND.getStatusCode());
                case UPDATED:
                case UP_TO_DATE:
View Full Code Here

TOP

Related Classes of org.lilyproject.tools.import_.json.WriteOptions

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.