@Override public Object getValue(Object instance) { if (instance != null) { Property<Object> property = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new NamedPropertyCriteria(propertyName)) .getFirstResult(); if (property != null) { return property.getValue(instance); } } return null; }
protected Property getNamedProperty(String propertyName, Class<?> type) { return PropertyQueries.<String>createQuery(type) .addCriteria(new NamedPropertyCriteria(propertyName)) .getFirstResult(); }
@Override public void setValue(Object instance, Object value) { if (instance != null) { Property<Object> property = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new NamedPropertyCriteria(propertyName)) .getFirstResult(); if (property != null) { property.setValue(instance, value); } } } }, mappedProperty);
protected Property getNamedProperty(String propertyName, Class<?> type) { return PropertyQueries.<String>createQuery(type) .addCriteria(new NamedPropertyCriteria(propertyName)) .getFirstResult(); }
@Override public Object getValue(Object instance) { if (instance != null) { Property<Object> property = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new NamedPropertyCriteria(propertyName)) .getFirstResult(); if (property != null) { return property.getValue(instance); } } return null; }
@Override public void setValue(Object instance, Object value) { if (instance != null) { Property<Object> property = PropertyQueries .createQuery(instance.getClass()) .addCriteria(new NamedPropertyCriteria(propertyName)) .getFirstResult(); if (property != null) { property.setValue(instance, value); } } } }, mappedProperty);
List<Property<Serializable>> attributeProperties = PropertyQueries .<Serializable>createQuery(o1.getClass()) .addCriteria(new NamedPropertyCriteria(attributeParameter.getName())).getResultList();
List<Property<Serializable>> attributeProperties = PropertyQueries .<Serializable>createQuery(o1.getClass()) .addCriteria(new NamedPropertyCriteria(attributeParameter.getName())).getResultList();
private void resolveIdentityTypes(RelationshipReference reference) { Relationship relationship = reference.getRelationship(); for (String descriptor : reference.getIdentityTypeReference().keySet()) { String identifier = reference.getIdentityTypeReference().get(descriptor); IdentityType identityType = IdentityTypeUtil.resolveIdentityType(identifier, relationship, getPartitionManager()); Property<Object> property = PropertyQueries .createQuery(relationship.getClass()) .addCriteria(new NamedPropertyCriteria(descriptor)) .getSingleResult(); property.setValue(relationship, identityType); } }
Property<AttributedType> relationshipProperty = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .addCriteria(new NamedPropertyCriteria(relationshipTypeProperty)) .getSingleResult();
private void resolveIdentityTypes(RelationshipReference reference) { Relationship relationship = reference.getRelationship(); for (String descriptor : reference.getIdentityTypeReference().keySet()) { String identifier = reference.getIdentityTypeReference().get(descriptor); IdentityType identityType = IdentityTypeUtil.resolveIdentityType(identifier, relationship, getPartitionManager()); Property<Object> property = PropertyQueries .createQuery(relationship.getClass()) .addCriteria(new NamedPropertyCriteria(descriptor)) .getSingleResult(); property.setValue(relationship, identityType); } }
public void registerRelationshipType(Class<? extends Relationship> relationshipType) { if (!privilegeChains.containsKey(relationshipType)) { List<Property<IdentityType>> properties = PropertyQueries.<IdentityType>createQuery(relationshipType) .addCriteria(new AnnotatedPropertyCriteria(InheritsPrivileges.class)) .addCriteria(new TypedPropertyCriteria(IdentityType.class, TypedPropertyCriteria.MatchOption.ALL)) .getResultList(); Map<Property<IdentityType>,Property<IdentityType>> inheritanceMapping = new HashMap<Property<IdentityType>,Property<IdentityType>>(); for (Property<IdentityType> p : properties) { InheritsPrivileges annotation = p.getAnnotatedElement().getAnnotation(InheritsPrivileges.class); String assigneeName = annotation.value(); if (StringUtil.isNullOrEmpty(assigneeName)) { throw new IllegalArgumentException(String.format("Specified relationshipType [%s] does not declare valid " + "@InheritsPrivilege annotation on property [%s] - missing assignee property name", relationshipType.getName(), p.getName())); } // Lookup the assignee property by name Property<IdentityType> assignee = PropertyQueries.<IdentityType>createQuery(relationshipType) .addCriteria(new NamedPropertyCriteria(assigneeName)) .getSingleResult(); inheritanceMapping.put(p, assignee); } privilegeChains.put(relationshipType, inheritanceMapping); } }
public void registerRelationshipType(Class<? extends Relationship> relationshipType) { if (!privilegeChains.containsKey(relationshipType)) { List<Property<IdentityType>> properties = PropertyQueries.<IdentityType>createQuery(relationshipType) .addCriteria(new AnnotatedPropertyCriteria(InheritsPrivileges.class)) .addCriteria(new TypedPropertyCriteria(IdentityType.class, TypedPropertyCriteria.MatchOption.ALL)) .getResultList(); Map<Property<IdentityType>,Property<IdentityType>> inheritanceMapping = new HashMap<Property<IdentityType>,Property<IdentityType>>(); for (Property<IdentityType> p : properties) { InheritsPrivileges annotation = p.getAnnotatedElement().getAnnotation(InheritsPrivileges.class); String assigneeName = annotation.value(); if (StringUtil.isNullOrEmpty(assigneeName)) { throw new IllegalArgumentException(String.format("Specified relationshipType [%s] does not declare valid " + "@InheritsPrivilege annotation on property [%s] - missing assignee property name", relationshipType.getName(), p.getName())); } // Lookup the assignee property by name Property<IdentityType> assignee = PropertyQueries.<IdentityType>createQuery(relationshipType) .addCriteria(new NamedPropertyCriteria(assigneeName)) .getSingleResult(); inheritanceMapping.put(p, assignee); } privilegeChains.put(relationshipType, inheritanceMapping); } }
@Override protected void validate() { if (this.mappedClass == null) { throw new SecurityConfigurationException("Mapped class not provided."); } if (this.hierarchySearchDepth < 0) { throw new SecurityConfigurationException("The hierarchy search depth can not be negative."); } if (!Relationship.class.isAssignableFrom(this.mappedClass)) { if (isNullOrEmpty(this.idPropertyName)) { throw new SecurityConfigurationException("No attribute provided as the identifier for mapped class [" + this.mappedClass + "]."); } } for (String propertyName : this.mappedProperties.keySet()) { Property<String> property = PropertyQueries.<String>createQuery(this.mappedClass).addCriteria(new NamedPropertyCriteria(propertyName)).getFirstResult(); if (property != null && !property.isAnnotationPresent(AttributeProperty.class) && !Relationship.class.isAssignableFrom(this.mappedClass)) { throw new SecurityConfigurationException("Mapped properties must be annotated with @AttributeProperty. Property [" + this.mappedClass + "." + propertyName + "]."); } } }
@Override protected void validate() { if (this.mappedClass == null) { throw new SecurityConfigurationException("Mapped class not provided."); } if (this.hierarchySearchDepth < 0) { throw new SecurityConfigurationException("The hierarchy search depth can not be negative."); } if (!Relationship.class.isAssignableFrom(this.mappedClass)) { if (isNullOrEmpty(this.idPropertyName)) { throw new SecurityConfigurationException("No attribute provided as the identifier for mapped class [" + this.mappedClass + "]."); } } for (String propertyName : this.mappedProperties.keySet()) { Property<String> property = PropertyQueries.<String>createQuery(this.mappedClass).addCriteria(new NamedPropertyCriteria(propertyName)).getFirstResult(); if (property != null && !property.isAnnotationPresent(AttributeProperty.class) && !Relationship.class.isAssignableFrom(this.mappedClass)) { throw new SecurityConfigurationException("Mapped properties must be annotated with @AttributeProperty. Property [" + this.mappedClass + "." + propertyName + "]."); } } }
Property<AttributedType> relProperty = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .addCriteria(new NamedPropertyCriteria(typeProperty)) .getSingleResult();
protected StoreConfiguration buildStoreConfiguration(StoreConfigurationType storeConfigType) { String className = storeConfigType.getClassName(); if (className == null) { throw new SecurityConfigurationException("Classname of all storeConfigurationTypes must be provided!"); } StoreConfiguration storeConfig = (StoreConfiguration)instantiateComponent(className); Class<?> storeConfigClass = storeConfig.getClass(); Map<String, Object> props = storeConfigType.getAllProperties(); for (String propertyName : props.keySet()) { // It's not optimal as we need to query and iterate methods separately for each property. // But performance shouldn't be big deal during reading configuration as it usually needs to be read only once... PropertyQuery<Object> propertyQuery = PropertyQueries.createQuery(storeConfigClass); propertyQuery.addCriteria(new NamedPropertyCriteria(propertyName)); Property<Object> property = propertyQuery.getWritableSingleResult(); // Obtain value from XML configuration Object propertyValueFromConfig = props.get(propertyName); // Create real instance of property from XML configuration Object propertyValue = PropertyResolverMapper.getInstance().resolveProperty(propertyValueFromConfig, property.getJavaClass()); // Set property to current storeConfiguration property.setValue(storeConfig, propertyValue); } return storeConfig; }
this.idProperty = PropertyQueries .<String>createQuery(getMappedClass()) .addCriteria(new NamedPropertyCriteria(idPropertyName)).getFirstResult(); } else { this.idProperty = null;
@SuppressWarnings("unchecked") @Override protected V resolvePropertyFromObjectType(ObjectType objectType) { // TODO: this code is almost the same like XMLBasedIdentityManagerProvider.buildStoreConfiguration String className = objectType.getClassName(); if (className == null) { throw new SecurityConfigurationException("ClassName must be always configured for all 'Object' types from configuration"); } V object = (V) XMLBasedIdentityManagerProvider.instantiateComponent(className); Class<?> objectClass = object.getClass(); Map<String, Object> props = objectType.getAllProperties(); for (String propertyName : props.keySet()) { // It's not optimal as we need to query and iterate methods separately for each property. // But performance shouldn't be big deal during reading configuration as it usually needs to be read only once... PropertyQuery<Object> propertyQuery = PropertyQueries.createQuery(objectClass); propertyQuery.addCriteria(new NamedPropertyCriteria(propertyName)); Property<Object> property = propertyQuery.getWritableSingleResult(); // Obtain value from XML configuration Object propertyValueFromConfig = props.get(propertyName); // Create real instance of property from XML configuration Object propertyValue = PropertyResolverMapper.getInstance().resolveProperty(propertyValueFromConfig, property.getJavaClass()); // Set property to current storeConfiguration property.setValue(object, propertyValue); } return object; }
Property<Object> property = PropertyQueries .createQuery(attributedType.getClass()) .addCriteria(new NamedPropertyCriteria(mappedAttribute.value())) .getFirstResult();