use of org.structr.core.property.PropertyKey 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.core.property.PropertyKey in project structr by structr.
the class QueryConfig method handleTypeArguments.
public void handleTypeArguments(final SecurityContext securityContext, final Class type, final List<Argument> arguments) throws FrameworkException {
// parse arguments
for (final Argument argument : arguments) {
final String name = argument.getName();
final Value value = argument.getValue();
switch(name) {
case "_page":
this.page = getIntegerValue(value, 1);
break;
case "_pageSize":
case "_first":
this.pageSize = getIntegerValue(value, Integer.MAX_VALUE);
break;
case "_sort":
this.sortKeySource = getStringValue(value, "name");
this.sortKey = StructrApp.getConfiguration().getPropertyKeyForJSONName(type, sortKeySource, false);
break;
case "_desc":
this.sortDescending = getBooleanValue(value, false);
break;
default:
// handle simple selections like an _equals on the field
final PropertyKey key = StructrApp.getConfiguration().getPropertyKeyForJSONName(type, name, false);
if (key != null) {
addAttribute(key, key.getSearchAttribute(securityContext, Occurrence.REQUIRED, castValue(securityContext, type, key, value), true, null), Occurrence.REQUIRED);
}
break;
}
}
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class JarConfigurationProvider method registerPropertySet.
/**
* Registers the given set of property keys for the view with name
* <code>propertyView</code> and the given prefix of entities with the
* given type.
*
* @param type the type of the entities for which the view will be
* registered
* @param propertyView the name of the property view for which the
* property set will be registered
* @param propertySet the set of property keys to register for the given
* view
*/
@Override
public void registerPropertySet(Class type, String propertyView, PropertyKey... propertySet) {
Map<String, Set<PropertyKey>> propertyViewMap = getPropertyViewMapForType(type);
Set<PropertyKey> properties = propertyViewMap.get(propertyView);
if (properties == null) {
properties = new LinkedHashSet<>();
propertyViewMap.put(propertyView, properties);
}
// are most likely from a more concrete class.
for (final PropertyKey key : propertySet) {
// between different keys
if (properties.contains(key)) {
properties.remove(key);
}
properties.add(key);
}
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class JarConfigurationProvider method getPropertyKeyForDatabaseName.
@Override
public PropertyKey getPropertyKeyForDatabaseName(Class type, String dbName, boolean createGeneric) {
Map<String, PropertyKey> classDBNamePropertyMap = getClassDBNamePropertyMapForType(type);
PropertyKey key = classDBNamePropertyMap.get(dbName);
if (key == null) {
// first try: uuid
if (GraphObject.id.dbName().equals(dbName)) {
return GraphObject.id;
}
if (createGeneric) {
key = new GenericProperty(dbName);
}
}
return key;
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class Resource method findPropertyKey.
// ----- protected methods -----
protected PropertyKey findPropertyKey(final TypedIdResource typedIdResource, final TypeResource typeResource) {
Class sourceNodeType = typedIdResource.getTypeResource().getEntityClass();
String rawName = typeResource.getRawType();
PropertyKey key = StructrApp.getConfiguration().getPropertyKeyForJSONName(sourceNodeType, rawName, false);
if (key == null) {
// try to convert raw name into lower-case variable name
key = StructrApp.getConfiguration().getPropertyKeyForJSONName(sourceNodeType, CaseHelper.toLowerCamelCase(rawName), false);
}
return key;
}
Aggregations