Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.FieldType


            Iterator<Map.Entry<String, JsonNode>> it = fields.getFields();
            while (it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();

                QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
                FieldType fieldType = repository.getTypeManager().getFieldTypeByName(qname);
                ValueHandle subHandle = new ValueHandle(fields.get(entry.getKey()), "fields." + entry.getKey(),
                        fieldType.getValueType());
                Object value = readValue(subHandle, context);
                if (value != null) {
                    record.setField(qname, value);
                } else if (value == null && deleteNullFields() && topLevelRecord) {
                    record.delete(qname, true);
View Full Code Here


        //
        // Condition on field
        //
        String fieldAttr = DocumentHelper.getAttribute(element, "field", false);
        FieldType fieldType = null;
        RecordMatcher.FieldComparator comparator = null;
        Object fieldValue = null;
        if (fieldAttr != null) {
            int eqPos = fieldAttr.indexOf('='); // we assume = is not a symbol occurring in the field name
            if (eqPos == -1) {
                throw new IndexerConfException("field test should be of the form \"namespace:name(=|!=)value\", which " +
                        "the following is not: " + fieldAttr + ", at " + LocationAttributes.getLocation(element));
            }

            // not-equals support (simplistic parsing approach, doesn't need anything more complex for now)
            String namePart = fieldAttr.substring(0, eqPos);
            if (namePart.endsWith("!")) {
                namePart = namePart.substring(0, namePart.length() - 1);
                comparator = RecordMatcher.FieldComparator.NOT_EQUAL;
            } else {
                comparator = RecordMatcher.FieldComparator.EQUAL;
            }

            QName fieldName = ConfUtil.parseQName(namePart, element);
            fieldType = typeManager.getFieldTypeByName(fieldName);
            String fieldValueString = fieldAttr.substring(eqPos + 1);
            try {
                fieldValue = FieldValueStringConverter.fromString(fieldValueString, fieldType.getValueType(),
                        repository.getIdGenerator());
            } catch (IllegalArgumentException e) {
                throw new IndexerConfException("Invalid field value: " + fieldValueString);
            }
        }
View Full Code Here

                checkSystemFieldUsage(fieldEl, valueExpr, fieldDependency, new QName(SystemFields.NS, "id"));
                checkSystemFieldUsage(fieldEl, valueExpr, fieldDependency, new QName(SystemFields.NS, "link"));
            }
        }

        final FieldType fieldType = constructDerefFieldType(fieldEl, valueExpr, derefParts);
        final DerefValue deref = new DerefValue(follows, value, fieldType, extractContent, formatter);

        deref.init(typeManager);
        return deref;
    }
View Full Code Here

        return ConfUtil.getFieldType(targetFieldName, systemFields, typeManager);
    }

    private Follow processFieldDeref(Element fieldEl, String derefPart)
            throws IndexerConfException, InterruptedException, RepositoryException {
        FieldType followField = ConfUtil.getFieldType(derefPart, fieldEl, systemFields, typeManager);

        String type = followField.getValueType().getBaseName();
        if (type.equals("LIST")) {
            type = followField.getValueType().getNestedValueType().getBaseName();
        }

        if (type.equals("RECORD")) {
            return new RecordFieldFollow(followField);
        } else if (type.equals("LINK")) {
            return new LinkFieldFollow(followField);
        } else {
            throw new IndexerConfException("Dereferencing is not possible on field of type " +
                    followField.getValueType().getName() + ". Field: '" + derefPart);
        }
    }
View Full Code Here

            if (options.getIncludeSchema()) {
                schemaNode = recordNode.putObject("schema");
            }

            for (Map.Entry<QName, Object> field : fields.entrySet()) {
                FieldType fieldType = repository.getTypeManager().getFieldTypeByName(field.getKey());
                String fieldName = QNameConverter.toJson(fieldType.getName(), namespaces);

                // fields entry
                fieldsNode.put(
                        fieldName,
                        valueToJson(field.getValue(), fieldType.getValueType(), options, namespaces, repository));

                // schema entry
                if (schemaNode != null) {
                    schemaNode.put(fieldName, FieldTypeWriter.toJson(fieldType, namespaces, false));
                }
View Full Code Here

    }

    private TemplatePart buildFieldTemplatePart(Element el, String template, String expr)
            throws IndexerConfException, InterruptedException, RepositoryException {
        QName field = ConfUtil.parseQName(expr, el);
        FieldType fieldType = ConfUtil.getFieldType(field, systemFields, repository.getTypeManager());
        return new FieldTemplatePart(fieldType, field);
    }
View Full Code Here

    @POST
    @Consumes("application/json")
    @Produces("application/json")
    public Response post(PostAction<FieldType> postAction, @Context UriInfo uriInfo) {
        FieldType fieldType = processPost(postAction);
        URI uri = uriInfo.getBaseUriBuilder().path(FieldTypeByIdResource.class).build(fieldType.getId());
        return Response.created(uri).entity(Entity.create(fieldType, uriInfo)).build();
    }
View Full Code Here

    @POST
    @Consumes("application/json")
    @Produces("application/json")
    public Response post(PostAction<FieldType> postAction, @Context UriInfo uriInfo) {
        FieldType fieldType = processPost(postAction);
        URI uri = uriInfo.getBaseUriBuilder().path(FieldTypeResource.class).
                queryParam("ns.n", fieldType.getName().getNamespace()).
                build("n$" + fieldType.getName().getName());
        return Response.created(uri).entity(Entity.create(fieldType, uriInfo)).build();
    }
View Full Code Here

    protected FieldType processPost(PostAction<FieldType> postAction) {
        if (!postAction.getAction().equals("create")) {
            throw new ResourceException("Unsupported POST action: " + postAction.getAction(), BAD_REQUEST.getStatusCode());
        }

        FieldType fieldType = postAction.getEntity();
        try {
            fieldType = typeManager.createFieldType(fieldType);
        } catch (FieldTypeExistsException e) {
            throw new ResourceException(e, CONFLICT.getStatusCode());
        } catch (Exception e) {
View Full Code Here

        CompareOp compareOp = filter.getCompareOp() != null ? filter.getCompareOp() : CompareOp.EQUAL;
        if (compareOp != CompareOp.EQUAL && compareOp != CompareOp.NOT_EQUAL) {
            throw new IllegalArgumentException("FieldValueFilter does not support this compare operator: " + compareOp);
        }

        FieldType fieldType = repository.getTypeManager().getFieldTypeByName(filter.getField());
        DataOutput dataOutput = new DataOutputImpl();
        fieldType.getValueType().write(filter.getFieldValue(), dataOutput, new IdentityRecordStack());
        byte[] fieldValue = dataOutput.toByteArray();

        LilyFieldSingleColumnValueFilter hbaseFilter = new LilyFieldSingleColumnValueFilter(RecordCf.DATA.bytes,
                ((FieldTypeImpl)fieldType).getQualifier(), HBaseRecordFilterUtil.translateCompareOp(compareOp), fieldValue);
        hbaseFilter.setFilterIfMissing(filter.getFilterIfMissing());
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.FieldType

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.