Package org.apache.stanbol.entityhub.servicesapi.query

Examples of org.apache.stanbol.entityhub.servicesapi.query.ReferenceConstraint


                throw new IllegalArgumentException(message.toString());
            } else {
                refList = Collections.singletonList(NamespaceEnum.getFullName(jConstraint.getString("value")));
            }
            MODE mode = parseConstraintValueMode(jConstraint);
            return new ReferenceConstraint(refList,mode);
        } else {
            log.warn("Parsed ReferenceConstraint does not define the required field \"value\"!");
            StringBuilder message = new StringBuilder();
            message.append("Parsed ReferenceConstraint does not define the required field 'value'!\n");
            message.append("Parsed Constraint: \n");
View Full Code Here


    @Override
    public Collection<Object> listSubjects(Object property, Object object) {
        FieldQuery query = createQuery();
        if(this.isURI(object)){
            query.setConstraint(property.toString(), new ReferenceConstraint(object.toString()));
        } else if(object instanceof Text){
            Text text = (Text)object;
            TextConstraint constraint;
            if(text.getLanguage() == null){
                constraint = new TextConstraint(text.getText(), PatternType.none, true);
View Full Code Here

                //  * currently References > Text > Datatype. First present value
                //    is used
                //  * non Reference | Text | Datatype values are ignored
                if (!ids.isEmpty()) {
                    // only references -> create reference constraint
                    query.setConstraint(property.getName(), new ReferenceConstraint(ids));
                    if (ids.size() != propertyEntry.getValue().size()) {
                        log.info("Only some of the parsed values of the field {} contain"
                                 + "references -> will ignore values with missing references");
                    }
                } else if (!texts.isEmpty()) {
                    // NOTE: This will use OR over all texts. To enforce AND one
                    // would need to parse a single string with all values e.g. by
                    // using StringUtils.join(texts," ")
                    query.setConstraint(property.getName(), new TextConstraint(texts));
                    if (ids.size() != propertyEntry.getValue().size()) {
                        log.info("Only some of the parsed values of the field {} are"
                                 + "of type String -> will ignore non-string values");
                    }
                } else if(!values.isEmpty()){
                    query.setConstraint(property.getName(), new ValueConstraint(values));
                } //else no values ... ignore property
            }
            //clean up
            ids.clear();
            texts.clear();
            values.clear();
        }
        //now add constraints for the collected special properties
        if(!references.isEmpty()){
            //add references constraint
            ReferenceConstraint refConstraint = new ReferenceConstraint(references, MODE.all);
            query.setConstraint(SpecialFieldEnum.references.getUri(), refConstraint);
        }
        if(!fullText.isEmpty()){
            TextConstraint textConstraint = new TextConstraint(fullText);
            query.setConstraint(SpecialFieldEnum.fullText.getUri(), textConstraint);
View Full Code Here

                    }
                } //else null -> ignore
            }
        }
        if (!types.isEmpty()) {
            query.setConstraint(TYPE_FIELD, new ReferenceConstraint(types));
        }
    }
View Full Code Here

        }
        query.setConstraint(nameField, labelConstraint);
        if (OntologicalClasses.DBPEDIA_PERSON.equals(namedEntity.getType())) {
            if (personState) {
                if (personType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(personType));
                }
                // else no type constraint
            } else {
                // ignore people
                return Collections.emptyList();
            }
        } else if (DBPEDIA_ORGANISATION.equals(namedEntity.getType())) {
            if (orgState) {
                if (orgType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(orgType));
                }
                // else no type constraint
            } else {
                // ignore people
                return Collections.emptyList();
            }
        } else if (OntologicalClasses.DBPEDIA_PLACE.equals(namedEntity.getType())) {
            if (this.placeState) {
                if (this.placeType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(placeType));
                }
                // else no type constraint
            } else {
                // ignore people
                return Collections.emptyList();
View Full Code Here

        // replace spaces with plus to create an AND search for all words in the name!
        query.setConstraint(nameField, new TextConstraint(namedEntity.getName()));// name.replace(' ', '+')));
        if (OntologicalClasses.DBPEDIA_PERSON.equals(namedEntity.getType())) {
            if (personState) {
                if (personType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(personType));
                }
                // else no type constraint
            } else {
                // ignore people
                return Collections.emptyList();
            }
        } else if (DBPEDIA_ORGANISATION.equals(namedEntity.getType())) {
            if (orgState) {
                if (orgType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(orgType));
                }
                // else no type constraint
            } else {
                // ignore people
                return Collections.emptyList();
            }
        } else if (OntologicalClasses.DBPEDIA_PLACE.equals(namedEntity.getType())) {
            if (this.placeState) {
                if (this.placeType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(placeType));
                }
                // else no type constraint
            } else {
                // ignore people
                return Collections.emptyList();
View Full Code Here

     * @throws JSONException
     */
    private static Constraint parseReferenceConstraint(JSONObject jConstraint) throws JSONException {
        Constraint constraint;
        if(jConstraint.has("value") && !jConstraint.isNull("value")){
            constraint = new ReferenceConstraint(jConstraint.getString("value"));
        } else {
            log.warn("Parsed ReferenceConstraint does not define the required field \"value\"!");
            StringBuilder message = new StringBuilder();
            message.append("Parsed ReferenceConstraint does not define the required field 'value'!\n");
            message.append("Parsed Constraint: \n");
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.query.ReferenceConstraint

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.