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

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


    private static JSONObject convertConstraintToJSON(Constraint constraint) throws JSONException {
        JSONObject jConstraint = new JSONObject();
        jConstraint.put("type", constraint.getType().name());
        switch (constraint.getType()) {
            case value: //both ValueConstraint and ReferenceConstraint
                ValueConstraint valueConstraint = ((ValueConstraint) constraint);
                if (valueConstraint.getValue() != null) {
                    jConstraint.put("value", valueConstraint.getValue());
                }
                if(constraint instanceof ReferenceConstraint){
                    //the type "reference" is not present in the ConstraintType
                    //enum, because internally ReferenceConstraints are just a
                    //ValueConstraint with a predefined data type, but "reference"
                    //is still a valid value of the type property in JSON
                    jConstraint.put("type", "reference");
                } else { // valueConstraint
                    jConstraint.put("type", constraint.getType().name());
                    //for valueConstraints we need to add also the dataType(s)
                    Collection<String> dataTypes = valueConstraint.getDataTypes();
                    if (dataTypes != null && !dataTypes.isEmpty()) {
                        if(dataTypes.size() == 1) {
                            jConstraint.put("datatype", NamespaceEnum.getShortName(dataTypes.iterator().next()));
                        } else {
                            ArrayList<String> dataTypeValues = new ArrayList<String>(dataTypes.size());
View Full Code Here

TOP

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

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.