use of org.structr.api.search.Occurrence in project structr by structr.
the class UuidSearchAttribute method includeInResult.
@Override
public boolean includeInResult(final GraphObject entity) {
String nodeValue = entity.getProperty(getKey());
Occurrence occur = getOccurrence();
String searchValue = getValue();
if (occur.equals(Occurrence.FORBIDDEN)) {
if ((nodeValue != null) && compare(nodeValue, searchValue) == 0) {
// don't add, do not check other results
return false;
}
} else {
if (nodeValue != null) {
if (compare(nodeValue, searchValue) != 0) {
return false;
}
} else {
if (searchValue != null && StringUtils.isNotBlank(searchValue)) {
return false;
}
}
}
return true;
}
use of org.structr.api.search.Occurrence in project structr by structr.
the class QueryConfig method handleFieldArguments.
public void handleFieldArguments(final SecurityContext securityContext, final Class type, final Field parentField, final Field field) throws FrameworkException {
final ConfigurationProvider config = StructrApp.getConfiguration();
final PropertyKey parentKey = config.getPropertyKeyForJSONName(type, parentField.getName());
final PropertyKey key = config.getPropertyKeyForJSONName(type, field.getName(), false);
final List<SearchTuple> searchTuples = new LinkedList<>();
Occurrence occurrence = Occurrence.REQUIRED;
// parse arguments
for (final Argument argument : field.getArguments()) {
final String name = argument.getName();
final Value value = argument.getValue();
switch(name) {
case "_equals":
searchTuples.add(new SearchTuple(castValue(securityContext, key.relatedType(), key, value), true));
break;
case "_contains":
searchTuples.add(new SearchTuple(castValue(securityContext, key.relatedType(), key, value), false));
break;
case "_conj":
occurrence = getOccurrence(value);
break;
default:
break;
}
}
// only add field if a value was set
for (final SearchTuple tuple : searchTuples) {
addAttribute(parentKey, key.getSearchAttribute(securityContext, occurrence, tuple.value, tuple.exact, null), occurrence);
}
}
use of org.structr.api.search.Occurrence in project structr by structr.
the class EmptySearchAttribute method includeInResult.
@Override
public boolean includeInResult(GraphObject entity) {
Occurrence occur = getOccurrence();
T searchValue = getValue();
T nodeValue = entity.getProperty(getKey());
if (occur.equals(Occurrence.FORBIDDEN)) {
if ((nodeValue != null) && !equal(nodeValue, searchValue)) {
// don't add, do not check other results
return false;
}
} else {
if (nodeValue != null) {
if (!equal(nodeValue, searchValue)) {
return false;
}
} else {
if (searchValue != null) {
return false;
}
}
}
return true;
}
use of org.structr.api.search.Occurrence in project structr by structr.
the class NotBlankSearchAttribute method includeInResult.
@Override
public boolean includeInResult(GraphObject entity) {
Occurrence occur = getOccurrence();
T nodeValue = entity.getProperty(getKey());
if (occur.equals(Occurrence.FORBIDDEN)) {
// reverse
return nodeValue == null;
} else {
return nodeValue != null;
}
}
use of org.structr.api.search.Occurrence in project structr by structr.
the class PropertySearchAttribute method includeInResult.
@Override
public boolean includeInResult(final GraphObject entity) {
T nodeValue = entity.getProperty(getKey());
Occurrence occur = getOccurrence();
T searchValue = getValue();
if (occur.equals(Occurrence.FORBIDDEN)) {
if ((nodeValue != null) && compare(nodeValue, searchValue) == 0) {
// don't add, do not check other results
return false;
}
} else {
if (nodeValue != null) {
if (!isExactMatch) {
if (nodeValue instanceof String && searchValue instanceof String) {
String n = (String) nodeValue;
String s = (String) searchValue;
return StringUtils.containsIgnoreCase(n, s);
}
}
if (compare(nodeValue, searchValue) != 0) {
return false;
}
} else {
if (searchValue != null && StringUtils.isNotBlank(searchValue.toString())) {
return false;
}
}
}
return true;
}
Aggregations