private IndexConstraint createIndexConstraint(Entry<String,Constraint> fieldConstraint) { IndexConstraint indexConstraint = new IndexConstraint(fieldConstraint.getKey(),fieldConstraint.getValue()); switch (fieldConstraint.getValue().getType()) { case value: initValueConstraint(indexConstraint); break; case text: initTextConstraint(indexConstraint); break; case range: initRangeConstraint(indexConstraint); break; case similarity: // handled by the caller directly pass break; default: indexConstraint.setInvalid(String.format("ConstraintType %s not supported by!", fieldConstraint.getValue().getType())); } return indexConstraint; }
/** * Utility method that copies over the {@link Constraint#getBoost()} value * to the {@link ConstraintValue} */ private void addBoost(ConstraintValue constraintValue, Constraint constraint){ Double boost = constraint.getBoost(); if(boost != null && boost != 1.0){ constraintValue.setProperty(QueryConst.QUERY_BOOST, constraint.getBoost()); } } /**
@Override public String toString() { StringBuilder query = new StringBuilder(); query.append(String.format("Query Constraints (%d)\n", this.queryConstraint.size())); for (Entry<String,Constraint> entry : this.queryConstraint.entrySet()) { query.append(String.format("[key:: %s][%s]\n", entry.getKey(), entry.getValue().toString())); } query.append(String.format("unmod Query Elements (%d)\n", this.unmodQueryElements.size())); for (Entry<String,Constraint> entry : this.unmodQueryElements.entrySet()) { query.append(String.format("[key:: %s][%s]\n", entry.getKey(), entry.getValue().toString())); } query.append(String.format("Selected (%d)\n", this.selected.size())); for (String entry : this.selected) { query.append(String.format("[%s]", entry)); } query.append(String.format("unmod Selected (%d)\n", this.unmodSelected.size())); for (String entry : this.unmodSelected) { query.append(String.format("[%s]", entry)); } query.append(String.format("[limit :: %d]\n", this.limit)); query.append(String.format("[offset :: %d]\n", this.offset)); return query.toString(); }
throw new IllegalArgumentException(message.toString()); } else { constraint.setBoost(boost);
private IndexConstraint createIndexConstraint(Entry<String,Constraint> fieldConstraint) { IndexConstraint indexConstraint = new IndexConstraint(fieldConstraint.getKey(),fieldConstraint.getValue()); switch (fieldConstraint.getValue().getType()) { case value: initValueConstraint(indexConstraint); break; case text: initTextConstraint(indexConstraint); break; case range: initRangeConstraint(indexConstraint); break; case similarity: // handled by the caller directly pass break; default: indexConstraint.setInvalid(String.format("ConstraintType %s not supported by!", fieldConstraint.getValue().getType())); } return indexConstraint; }
/** * Utility method that copies over the {@link Constraint#getBoost()} value * to the {@link ConstraintValue} */ private void addBoost(ConstraintValue constraintValue, Constraint constraint){ Double boost = constraint.getBoost(); if(boost != null && boost != 1.0){ constraintValue.setProperty(QueryConst.QUERY_BOOST, constraint.getBoost()); } } /**
@Override public String toString() { StringBuilder query = new StringBuilder(); query.append(String.format("Query Constraints (%d)\n", this.queryConstraint.size())); for (Entry<String,Constraint> entry : this.queryConstraint.entrySet()) { query.append(String.format("[key:: %s][%s]\n", entry.getKey(), entry.getValue().toString())); } query.append(String.format("unmod Query Elements (%d)\n", this.unmodQueryElements.size())); for (Entry<String,Constraint> entry : this.unmodQueryElements.entrySet()) { query.append(String.format("[key:: %s][%s]\n", entry.getKey(), entry.getValue().toString())); } query.append(String.format("Selected (%d)\n", this.selected.size())); for (String entry : this.selected) { query.append(String.format("[%s]", entry)); } query.append(String.format("unmod Selected (%d)\n", this.unmodSelected.size())); for (String entry : this.unmodSelected) { query.append(String.format("[%s]", entry)); } query.append(String.format("[limit :: %d]\n", this.limit)); query.append(String.format("[offset :: %d]\n", this.offset)); return query.toString(); }
if(mapping.getFilter().getType() == ConstraintType.text){ serializeConstraint(builder,(TextConstraint)mapping.getFilter()); } else if(mapping.getFilter().getType() == ConstraintType.value){ serializeConstraint(builder,(ValueConstraint)mapping.getFilter()); } else { throw new IllegalStateException(String.format("Constraints of type %s are not supported! Please adapt this implementation!",mapping.getFilter().getType()));
jFieldConstraint.put("field", fieldConstraint.getKey()); //add the field Double boost = fieldConstraint.getValue().getBoost(); if(boost != null){ jFieldConstraint.put("boost", boost);
if(mapping.getFilter().getType() == ConstraintType.text){ serializeConstraint(builder,(TextConstraint)mapping.getFilter()); } else if(mapping.getFilter().getType() == ConstraintType.value){ serializeConstraint(builder,(ValueConstraint)mapping.getFilter()); } else { throw new IllegalStateException(String.format("Constraints of type %s are not supported! Please adapt this implementation!",mapping.getFilter().getType()));
new Object[]{constraint.getType(), field, varPrefix, intend}); boolean added = true; switch (constraint.getType()) { case value: addValueConstraint(queryString, field, (ValueConstraint) constraint, selectedFields, log.warn("Constraint Type '{}' not supported in SPARQL! Constriant {} " + "will be not included in the query!", fieldConstraint.getValue().getType(), fieldConstraint.getValue()); added = false; break;
new Object[]{constraint.getType(), field, varPrefix, intend}); boolean added = true; switch (constraint.getType()) { case value: addValueConstraint(queryString, field, (ValueConstraint) constraint, selectedFields, log.warn("Constraint Type '{}' not supported in SPARQL! Constriant {} " + "will be not included in the query!", fieldConstraint.getValue().getType(), fieldConstraint.getValue()); added = false; break;
mapping.getFilter().getType() == ConstraintType.text){ //and of type text
mapping.getFilter().getType() == ConstraintType.text){ //and of type text
mapping.getFilter() != null && mapping.getFilter().getType() == ConstraintType.text){ filtered = new HashSet<Object>(values);//start with all values } else { //start with the values filtered by the global filter switch (mapping.getFilter().getType()) { case value: ValueConstraint valueConstraint = (ValueConstraint)mapping.getFilter(); default: log.warn(String.format("Filter of type %s are not supported -> select all values! (Constraint=%s)", mapping.getFilter().getType(),mapping.getFilter())); break;
mapping.getFilter() != null && mapping.getFilter().getType() == ConstraintType.text){ filtered = new HashSet<Object>(values);//start with all values } else { //start with the values filtered by the global filter switch (mapping.getFilter().getType()) { case value: ValueConstraint valueConstraint = (ValueConstraint)mapping.getFilter(); default: log.warn(String.format("Filter of type %s are not supported -> select all values! (Constraint=%s)", mapping.getFilter().getType(),mapping.getFilter())); break;
boolean similarityConstraintPresent = false; for (Entry<String,Constraint> fieldConstraint : fieldQuery) { if (fieldConstraint.getValue().getType() == ConstraintType.similarity) { log.warn("Unable to create IndexConstraint for Constraint {} (type: {}) and Field {} (Reosens: {})", new Object[]{ fieldConstraint.getValue(), fieldConstraint.getValue().getType(), fieldConstraint.getKey(), indexConstraint.getInvalidMessages() });
boolean similarityConstraintPresent = false; for (Entry<String,Constraint> fieldConstraint : fieldQuery) { if (fieldConstraint.getValue().getType() == ConstraintType.similarity) { log.warn("Unable to create IndexConstraint for Constraint {} (type: {}) and Field {} (Reosens: {})", new Object[]{ fieldConstraint.getValue(), fieldConstraint.getValue().getType(), fieldConstraint.getKey(), indexConstraint.getInvalidMessages() });
jConstraint.put("type", constraint.getType().name()); switch (constraint.getType()) { case value: //both ValueConstraint and ReferenceConstraint ValueConstraint valueConstraint = ((ValueConstraint) constraint); jConstraint.put("type", constraint.getType().name()); default: log.warn("Unsupported Constriant Type " + constraint.getType() + " (implementing class=" + constraint.getClass() + "| toString=" + constraint + ") -> skiped"); break;