Examples of IndexDataType


Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

     * @param rangeConstraint
     */
    private void initRangeConstraint(IndexConstraint indexConstraint) {
        RangeConstraint rangeConstraint = (RangeConstraint)indexConstraint.getConstraint();
        // we need to find the Index DataType for the range query
        IndexDataType dataType = null;
        if (rangeConstraint.getLowerBound() != null) {
            dataType = indexValueFactory.createIndexValue(rangeConstraint.getLowerBound()).getType();
        }
        if (rangeConstraint.getUpperBound() != null) {
            IndexDataType upperDataType = indexValueFactory.createIndexValue(rangeConstraint.getUpperBound())
                    .getType();
            if (dataType == null) {
                dataType = upperDataType;
            } else {
                if (!dataType.equals(upperDataType)) {
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

                    }
                }
            }
            //we support only a single dataType ...
            //  ... therefore remove additional data types from the ValueConstraint
            IndexDataType indexDataType = null;
            if(!indexDataTypes.isEmpty()) {
                indexDataType = indexDataTypes.get(0);
                if(indexDataTypes.size() > 1){
                    log.warn("Only a single DataType is supported for ValueConstraints!");
                    while(acceptedDataTypes.size()>1){
                        String ignored = acceptedDataTypes.remove(acceptedDataTypes.size()-1);
                        log.warn("  > ignore parsed dataType {}",ignored);
                    }
                }
            } //else empty we will initialise based on the first parsed value!
            ConstraintValue constraintValue = new ConstraintValue(valueConstraint.getMode());
            for(Object value : valueConstraint.getValues()){
                IndexValue indexValue;
                if(indexDataType == null){ // if no supported types are present
                    // get the dataType based on the type of the value
                    try {
                        indexValue = indexValueFactory.createIndexValue(value);
                    } catch (NoConverterException e) {
                        // if not found use the toString() and string as type
                        log.warn("Unable to create IndexValue for value {} (type: {}). Create IndexValue manually by using the first parsed IndexDataType {}",
                                    new Object[]{
                                        value, value.getClass(),
                                        IndexDataTypeEnum.STR.getIndexType()
                                    });
                        indexValue = new IndexValue(value.toString(),
                            IndexDataTypeEnum.STR.getIndexType());
                    }
                    //initialise the IndexDataType for this query based on the first parsed value
                    indexDataType = indexValue.getType();
                } else {
                    indexValue = new IndexValue(value.toString(), indexDataType);
                }
                constraintValue.getValues().add(indexValue); //add the constraint
            }
            //indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.DATATYPE, indexDataType);
            IndexField indexField;
            if(IndexDataTypeEnum.TXT.getIndexType().equals(indexDataType)){
                //NOTE: in case of TEXT we need also to add the language to create a valid
                //query!
                // * We take the language of the first parsed element
                indexField = new IndexField(indexConstraint.getPath(), indexDataType,
                    constraintValue.getValues().iterator().next().getLanguage());
            } else {
                indexField = new IndexField(indexConstraint.getPath(), indexDataType);
            }
            //set FIELD, DATATYPE and LANGUAGE constraint by using the indexField
            indexConstraint.setIndexFieldConstraints(indexField);
            //set the VALUE
            //TODO: We need to somehow pass the MODE so that the encoder knows how
            //      to encode the values
            indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue);
            //update this constraint!
            if(valueConstraint instanceof ReferenceConstraint){
                indexConstraint.setFieldQueryConstraint(valueConstraint);
            } else {
                indexConstraint.setFieldQueryConstraint(
                    new ValueConstraint(valueConstraint.getValues(), Arrays.asList(indexDataType.getId())));
            }
        }
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

     * @param rangeConstraint
     */
    private void initRangeConstraint(IndexConstraint indexConstraint) {
        RangeConstraint rangeConstraint = (RangeConstraint)indexConstraint.getConstraint();
        // we need to find the Index DataType for the range query
        IndexDataType dataType = null;
        ConstraintValue lowerBound = new ConstraintValue();
        ConstraintValue upperBound = new ConstraintValue();
        //init the boosts
        addBoost(lowerBound, rangeConstraint);
        addBoost(upperBound, rangeConstraint);
        //init IndexValues and check for the dataType
        if (rangeConstraint.getLowerBound() != null) {
            IndexValue value = indexValueFactory.createIndexValue(rangeConstraint.getLowerBound());
            lowerBound.getValues().add(value);
            dataType = value.getType();
        }
        if (rangeConstraint.getUpperBound() != null) {
            IndexValue value = indexValueFactory.createIndexValue(rangeConstraint.getUpperBound());
            upperBound.getValues().add(value);
            IndexDataType upperDataType = value.getType();
            if (dataType == null) {
                dataType = upperDataType;
            } else {
                if (!dataType.equals(upperDataType)) {
                    indexConstraint.setInvalid(String.format(
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

                    }
                }
            }
            //we support only a single dataType ...
            //  ... therefore remove additional data types from the ValueConstraint
            IndexDataType indexDataType = null;
            if(!indexDataTypes.isEmpty()) {
                indexDataType = indexDataTypes.get(0);
                if(indexDataTypes.size() > 1){
                    log.warn("Only a single DataType is supported for ValueConstraints!");
                    while(acceptedDataTypes.size()>1){
                        String ignored = acceptedDataTypes.remove(acceptedDataTypes.size()-1);
                        log.warn("  > ignore parsed dataType {}",ignored);
                    }
                }
            } //else empty we will initialise based on the first parsed value!
            ConstraintValue constraintValue = new ConstraintValue(valueConstraint.getMode());
            addBoost(constraintValue, valueConstraint); //init the boost
            for(Object value : valueConstraint.getValues()){
                IndexValue indexValue;
                if(indexDataType == null){ // if no supported types are present
                    // get the dataType based on the type of the value
                    try {
                        indexValue = indexValueFactory.createIndexValue(value);
                    } catch (NoConverterException e) {
                        // if not found use the toString() and string as type
                        log.warn("Unable to create IndexValue for value {} (type: {}). Create IndexValue manually by using the first parsed IndexDataType {}",
                                    new Object[]{
                                        value, value.getClass(),
                                        IndexDataTypeEnum.STR.getIndexType()
                                    });
                        indexValue = new IndexValue(value.toString(),
                            IndexDataTypeEnum.STR.getIndexType());
                    }
                    //initialise the IndexDataType for this query based on the first parsed value
                    indexDataType = indexValue.getType();
                } else {
                    indexValue = new IndexValue(value.toString(), indexDataType);
                }
                constraintValue.getValues().add(indexValue); //add the constraint
            }
            //indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.DATATYPE, indexDataType);
            IndexField indexField;
            if(IndexDataTypeEnum.TXT.getIndexType().equals(indexDataType)){
                //NOTE: in case of TEXT we need also to add the language to create a valid
                //query!
                // * We take the language of the first parsed element
                indexField = new IndexField(indexConstraint.getPath(), indexDataType,
                    constraintValue.getValues().iterator().next().getLanguage());
            } else {
                indexField = new IndexField(indexConstraint.getPath(), indexDataType);
            }
            //set FIELD, DATATYPE and LANGUAGE constraint by using the indexField
            indexConstraint.setIndexFieldConstraints(indexField);
            //set the VALUE
            //TODO: We need to somehow pass the MODE so that the encoder knows how
            //      to encode the values
            indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue);
            //update this constraint!
            if(valueConstraint instanceof ReferenceConstraint){
                indexConstraint.setFieldQueryConstraint(valueConstraint);
            } else {
                indexConstraint.setFieldQueryConstraint(
                    new ValueConstraint(valueConstraint.getValues(), Arrays.asList(indexDataType.getId())));
            }
        }
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

     * @param rangeConstraint
     */
    private void initRangeConstraint(IndexConstraint indexConstraint) {
        RangeConstraint rangeConstraint = (RangeConstraint)indexConstraint.getConstraint();
        // we need to find the Index DataType for the range query
        IndexDataType dataType = null;
        if (rangeConstraint.getLowerBound() != null) {
            dataType = indexValueFactory.createIndexValue(rangeConstraint.getLowerBound()).getType();
        }
        if (rangeConstraint.getUpperBound() != null) {
            IndexDataType upperDataType = indexValueFactory.createIndexValue(rangeConstraint.getUpperBound())
                    .getType();
            if (dataType == null) {
                dataType = upperDataType;
            } else {
                if (!dataType.equals(upperDataType)) {
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

                    }
                }
            }
            //we support only a single dataType ...
            //  ... therefore remove additional data types from the ValueConstraint
            IndexDataType indexDataType = null;
            if(!indexDataTypes.isEmpty()) {
                indexDataType = indexDataTypes.get(0);
                if(indexDataTypes.size() > 1){
                    log.warn("Only a single DataType is supported for ValueConstraints!");
                    while(acceptedDataTypes.size()>1){
                        String ignored = acceptedDataTypes.remove(acceptedDataTypes.size()-1);
                        log.warn("  > ignore parsed dataType {}",ignored);
                    }
                }
            } //else empty we will initialise based on the first parsed value!
            ConstraintValue constraintValue = new ConstraintValue(valueConstraint.getMode());
            for(Object value : valueConstraint.getValues()){
                IndexValue indexValue;
                if(indexDataType == null){ // if no supported types are present
                    // get the dataType based on the type of the value
                    try {
                        indexValue = indexValueFactory.createIndexValue(value);
                    } catch (NoConverterException e) {
                        // if not found use the toString() and string as type
                        log.warn("Unable to create IndexValue for value {} (type: {}). Create IndexValue manually by using the first parsed IndexDataType {}",
                                    new Object[]{
                                        value, value.getClass(),
                                        IndexDataTypeEnum.STR.getIndexType()
                                    });
                        indexValue = new IndexValue(value.toString(),
                            IndexDataTypeEnum.STR.getIndexType());
                    }
                    //initialise the IndexDataType for this query based on the first parsed value
                    indexDataType = indexValue.getType();
                } else {
                    indexValue = new IndexValue(value.toString(), indexDataType);
                }
                constraintValue.getValues().add(indexValue); //add the constraint
            }
            //indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.DATATYPE, indexDataType);
            IndexField indexField;
            if(IndexDataTypeEnum.TXT.getIndexType().equals(indexDataType)){
                //NOTE: in case of TEXT we need also to add the language to create a valid
                //query!
                // * We take the language of the first parsed element
                indexField = new IndexField(indexConstraint.getPath(), indexDataType,
                    constraintValue.getValues().iterator().next().getLanguage());
            } else {
                indexField = new IndexField(indexConstraint.getPath(), indexDataType);
            }
            //set FIELD, DATATYPE and LANGUAGE constraint by using the indexField
            indexConstraint.setIndexFieldConstraints(indexField);
            //set the VALUE
            //TODO: We need to somehow pass the MODE so that the encoder knows how
            //      to encode the values
            indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue);
            //update this constraint!
            if(valueConstraint instanceof ReferenceConstraint){
                indexConstraint.setFieldQueryConstraint(valueConstraint);
            } else {
                indexConstraint.setFieldQueryConstraint(
                    new ValueConstraint(valueConstraint.getValues(), Arrays.asList(indexDataType.getId())));
            }
        }
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

        this.indexValueFactory = indexValueFactory;
    }

    @Override
    public void encode(EncodedConstraintParts constraint, Object value) throws IllegalArgumentException {
        IndexDataType indexDataType;
        if (value == null) {
            indexDataType = null;
        } else if (value instanceof IndexDataType) {
            indexDataType = (IndexDataType) value;
        } else if (value instanceof IndexField) {
View Full Code Here

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexDataType

     * @param indexConstraint
     * @param rangeConstraint
     */
    private void initIndexConstraint(IndexConstraint indexConstraint, RangeConstraint rangeConstraint) {
        // we need to find the Index DataType for the range query
        IndexDataType dataType = null;
        if (rangeConstraint.getLowerBound() != null) {
            dataType = indexValueFactory.createIndexValue(rangeConstraint.getLowerBound()).getType();
        }
        if (rangeConstraint.getUpperBound() != null) {
            IndexDataType upperDataType = indexValueFactory.createIndexValue(rangeConstraint.getUpperBound())
                    .getType();
            if (dataType == null) {
                dataType = upperDataType;
            } else {
                if (!dataType.equals(upperDataType)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.