Package org.lilyproject.tools.import_.json

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


        }

        recordType = result.getEntity();
        Response response;

        ImportResultType resultType = result.getResultType();
        switch (resultType) {
            case UPDATED:
            case UP_TO_DATE:
                response = Response.ok(Entity.create(recordType, uriInfo)).build();
                break;
View Full Code Here


        }

        fieldType = result.getEntity();
        Response response;

        ImportResultType resultType = result.getResultType();
        switch (resultType) {
            case CREATED:
                URI uri = uriInfo.getBaseUriBuilder().path(FieldTypeResource.class).
                        queryParam("ns.n", fieldType.getName().getNamespace()).
                        build("n$" + fieldType.getName().getName());
View Full Code Here

        }

        recordType = result.getEntity();
        Response response;

        ImportResultType resultType = result.getResultType();
        switch (resultType) {
            case CREATED:
                URI uri = uriInfo.getBaseUriBuilder().path(RecordTypeResource.class).
                        queryParam("ns.n", recordType.getName().getNamespace()).
                        build("n$" + recordType.getName().getName());
View Full Code Here

        }

        fieldType = result.getEntity();
        Response response;

        ImportResultType resultType = result.getResultType();
        switch (resultType) {
            case UPDATED:
            case UP_TO_DATE:
                response = Response.ok(Entity.create(fieldType, uriInfo)).build();
                break;
View Full Code Here

        try {
            ObjectNode listNode = JsonNodeFactory.instance.objectNode();
            ArrayNode resultsNode = listNode.putArray("results");

            EntityWriter writer = getEntityWriter(genericType);
            for (Object entity : entityList.getEntities()) {
                // Multiple repositories: ok to use public repo since only non-repository-specific things are needed
                resultsNode.add(writer.toJson(entity, entityList.getWriteOptions(),
                        repositoryMgr.getDefaultRepository()));
            }

            JsonFormat.serialize(listNode, new CloseShieldOutputStream(entityStream));
        } catch (Throwable e) {
View Full Code Here

    @Override
    public void writeTo(Entity object, Class<?> type, Type genericType, Annotation[] annotations,
            MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
            throws IOException, WebApplicationException {
        try {
            EntityWriter writer = EntityRegistry.findWriter(object.getEntity().getClass());
            // Multiple repositories: ok to use public repo since only non-repository-specific things are needed
            ObjectNode json = writer.toJson(object.getEntity(), object.getWriteOptions(),
                    repositoryMgr.getDefaultRepository());
            JsonFormat.serialize(json, new CloseShieldOutputStream(entityStream));
        } catch (Throwable e) {
            // We catch every throwable, since otherwise no one does it and we will not have any trace
            // of Errors that happened.
View Full Code Here

        ArrayNode filters = JsonUtil.getArray(node, "filters", null);
        if (filters != null) {
            for (JsonNode subFilterNode : filters) {
                if (!subFilterNode.isObject()) {
                    throw new JsonFormatException("filters should contain a json object");
                }
                ObjectNode subFilterObjectNode = (ObjectNode)subFilterNode;
                filter.addFilter(converter.fromJson(subFilterObjectNode, namespaces, repository, converter));
            }
        }
View Full Code Here

        SystemFields systemFields = SystemFields.getInstance(repository.getTypeManager(), repository.getIdGenerator());

        for (int i = 0; i < conditions.size(); i++) {
            JsonNode conditionNode = conditions.get(i);
            if (!conditionNode.isObject()) {
                throw new JsonFormatException("Each element in the conditions array should be an object.");
            }

            QName fieldName = QNameConverter.fromJson(JsonUtil.getString(conditionNode, "field"), namespaces);

            JsonNode valueNode = conditionNode.get("value");
            Object value = null;
            if (!valueNode.isNull()) {
                FieldType fieldType = systemFields.isSystemField(fieldName) ? systemFields.get(fieldName) :
                        repository.getTypeManager().getFieldTypeByName(fieldName);
                value = RecordReader.INSTANCE.readValue(
                        new RecordReader.ValueHandle(valueNode, "value", fieldType.getValueType()),
                        new RecordReader.ReadContext(repositoryMgr.getDefaultRepository(), namespaces,linkTransformer));
            }

            boolean allowMissing = JsonUtil.getBoolean(conditionNode, "allowMissing", false);

            String operator = JsonUtil.getString(conditionNode, "operator", null);
            CompareOp op = CompareOp.EQUAL;
            if (operator != null) {
                try {
                    op = CompareOp.valueOf(operator.toUpperCase());
                } catch (IllegalArgumentException e) {
                    throw new JsonFormatException("Invalid comparison operator in mutation condition: " + operator);
                }
            }

            MutationCondition condition = new MutationCondition(fieldName, op, value, allowMissing);
            result.add(condition);
View Full Code Here

        String action = JsonUtil.getString(postNode, "action");
        List<MutationCondition> conditions;
        Object entity = null;

        try {
            Namespaces namespaces = NamespacesConverter.fromContextJsonIfAvailable(postNode);

            conditions = readMutationConditions(postNode, namespaces);

            // Hardcoded behavior that action 'delete' does not need a submitted entity (and any other does)
            if (!action.equals("delete")) {
View Full Code Here

            QName fieldQName = QNameConverter.fromJson(field, namespaces);
            filter.setField(fieldQName);
            ValueType valueType = repository.getTypeManager().getFieldTypeByName(fieldQName).getValueType();
            Object value = RecordReader.INSTANCE.readValue(
                    new RecordReader.ValueHandle(fieldValue, "fieldValue", valueType),
                    new RecordReader.ReadContext(repository, new NamespacesImpl(), defaultLinkTransformer));
            filter.setFieldValue(value);
        }

        String compareOp = JsonUtil.getString(node, "compareOp", null);
        if (compareOp != null) {
View Full Code Here

TOP

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

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.