Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.QName


        @Override
        public Object resolve(TemplatePart part) {
            RecordContext ctx = contexts.peek();
            //TODO: add dependencies caused by resolving name template variables
            if (part instanceof FieldTemplatePart) {
                QName fieldName = ((FieldTemplatePart) part).getFieldType().getName();
                if (ctx.record.hasField(fieldName)) {
                    return ctx.record.getField(fieldName);
                } else {
                    throw new NameTemplateEvaluationException(
                            "Error evaluating name template: Record does not have field " + fieldName);
View Full Code Here


        // Prepare record by generating values for the fields
        record.setRecordType(recordTypeToCreate.getRecordType().getName());
        List<TestFieldType> fieldTypesToCreate = recordTypeToCreate.getFieldTypes();
        for (TestFieldType testFieldType : fieldTypesToCreate) {
            QName fieldQName = testFieldType.getFieldType().getName();
            ActionResult result = testFieldType.generateValue(this);
            duration += result.duration;
            if (!result.success) {
                return new ActionResult(false, null, duration);
            }
View Full Code Here

        // Determine the vtag
        //
        SchemaId vtagId = null;
        if (cmd.hasOption(vtagOption.getOpt())) {
            String vtagParam = cmd.getOptionValue(vtagOption.getOpt());
            vtagId = typeManager.getFieldTypeByName(new QName("org.lilyproject.vtag", vtagParam)).getId();
        }

        //
        // Determine the field
        //
View Full Code Here

    private void printFieldedLinks(Set<FieldedLink> fieldedLinks) throws RepositoryException, InterruptedException {
        System.out.println("Result count: " + fieldedLinks.size());
        System.out.println();

        for (FieldedLink link : fieldedLinks) {
            QName fieldName = typeManager.getFieldTypeById(link.getFieldTypeId()).getName();
            System.out.println(link.getRecordId() + " -- " + fieldName);
        }
    }
View Full Code Here

        if ((field != null || fieldValue != null) && (field == null || fieldValue == null)) {
            throw new RuntimeException("FieldValueFilter deserialization: both field and fieldValue must be specified.");
        }

        if (field != null && fieldValue != null) {
            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));
View Full Code Here

            TypeManager typeManager = repository.getTypeManager();

            if (idxSel.getFieldChanges() != null) {
                for (RecordEvent.FieldChange fieldChange : idxSel.getFieldChanges()) {
                    FieldType fieldType = typeManager.getFieldTypeById(fieldChange.getId());
                    QName name = fieldType.getName();

                    if (fieldChange.getNewValue() != null) {
                        Object value = fieldType.getValueType().read(fieldChange.getNewValue());
                        newRecord.setField(name, value);
                    }
View Full Code Here

        this.tableNames = tableNames == null ? Sets.<String>newHashSet() : Sets.newHashSet(tableNames);
        this.typeManager = typeManager;
    }

    public boolean matches(String table, Record record) {
        QName recordTypeName = record.getRecordTypeName();
        Map<String, String> varProps = record.getId().getVariantProperties();

        // About "recordTypeName == null": normally record type name cannot be null, but it can
        // be in the case of IndexAwareMQFeeder
        if (this.recordTypeNamespace != null &&
                (recordTypeName == null || !this.recordTypeNamespace.lightMatch(recordTypeName.getNamespace()))) {
            return false;
        }

        if (!tableNames.isEmpty() && !tableNames.contains(table)) {
            return false;
        }

        if (this.recordTypeName != null
                && (recordTypeName == null || !this.recordTypeName.lightMatch(recordTypeName.getName()))) {
            return false;
        }

        try {
            if (this.instanceOfType != null
View Full Code Here

        WildcardPattern rtNamespacePattern = null;
        WildcardPattern rtNamePattern = null;

        String recordTypeAttr = DocumentHelper.getAttribute(element, "recordType", false);
        if (recordTypeAttr != null) {
            QName rtName = ConfUtil.parseQName(recordTypeAttr, element, true);
            rtNamespacePattern = new WildcardPattern(rtName.getNamespace());
            rtNamePattern = new WildcardPattern(rtName.getName());
        }

        //
        // "Instance of" condition
        //
        String instanceOfAttr = DocumentHelper.getAttribute(element, "instanceOf", false);
        QName instanceOfType = null;
        if (instanceOfAttr != null) {
            instanceOfType = ConfUtil.parseQName(instanceOfAttr, element, false);
        }

        List<String> tableNames = extractTableNames(DocumentHelper.getAttribute(element, "tables", false));

        //
        // Condition on variant properties
        //
        Map<String, String> varPropsPattern = parseVariantPropertiesPattern(element, "variant");

        //
        // 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());
View Full Code Here

        // If the last follow is a RecordFieldFollow, we check that the Value isn't something which requires a real Record
        if (lastFollowIsRecord) {
            SchemaId fieldDependency = value.getFieldDependency();
            if (systemFields.isSystemField(fieldDependency)) {
                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);
View Full Code Here

    private FieldType constructDerefFieldType(Element fieldEl, String valueExpr, String[] derefParts)
            throws IndexerConfException, InterruptedException, RepositoryException {
        //
        // Last element in the list should be a field
        //
        QName targetFieldName;
        try {
            targetFieldName = ConfUtil.parseQName(derefParts[derefParts.length - 1], fieldEl);
        } catch (IndexerConfException e) {
            throw new IndexerConfException("Dereference expression does not end on a valid field name. " +
                    "Expression: '" + valueExpr + "' at " + LocationAttributes.getLocationString(fieldEl), e);
View Full Code Here

TOP

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

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.