use of org.qi4j.api.common.QualifiedName in project qi4j-sdk by Qi4j.
the class NamedAssociationModel method bind.
@Override
public void bind(Resolution resolution) throws BindingException {
builderInfo = new AssociationInfo() {
@Override
public boolean isImmutable() {
return false;
}
@Override
public QualifiedName qualifiedName() {
return qualifiedName;
}
@Override
public Type type() {
return type;
}
@Override
public void checkConstraints(Object value) throws ConstraintViolationException {
NamedAssociationModel.this.checkConstraints(value);
}
};
if (type instanceof TypeVariable) {
Class mainType = first(resolution.model().types());
type = Classes.resolveTypeVariable((TypeVariable) type, ((Member) accessor).getDeclaringClass(), mainType);
}
}
use of org.qi4j.api.common.QualifiedName in project qi4j-sdk by Qi4j.
the class Triples method addTripleManyAssociation.
public Triple addTripleManyAssociation(final ManyAssociationFunction<?> manyAssociationReference, final boolean optional) {
AssociationFunction<?> traversedAssociation = manyAssociationReference.traversedAssociation();
String subject = "?entity";
if (traversedAssociation != null) {
subject = addTripleAssociation(traversedAssociation, false).value;
}
QualifiedName qualifiedName = QualifiedName.fromAccessor(manyAssociationReference.accessor());
String predicatePrefix = addNamespace(qualifiedName.toNamespace());
String predicate = predicatePrefix + ":" + qualifiedName.name();
Triple collectionTriple = addTriple(subject, predicate, optional);
String liSubject = collectionTriple.value;
return addTriple(liSubject, "rdf:li", false);
}
use of org.qi4j.api.common.QualifiedName in project qi4j-sdk by Qi4j.
the class GaeEntityState method initializeValueTypes.
private HashMap<QualifiedName, ValueType> initializeValueTypes(EntityDescriptor descriptor) {
HashMap<QualifiedName, ValueType> result = new HashMap<QualifiedName, ValueType>();
for (PropertyDescriptor persistent : descriptor.state().properties()) {
if (persistent.valueType() instanceof ValueCompositeType) {
QualifiedName name = persistent.qualifiedName();
result.put(name, persistent.valueType());
}
}
return result;
}
use of org.qi4j.api.common.QualifiedName in project qi4j-sdk by Qi4j.
the class ValueCompositeCxfType method readObject.
@Override
public Object readObject(final MessageReader reader, final Context context) throws DatabindingException {
QName qname = getSchemaType();
final String className = (qname.getNamespaceURI() + "." + qname.getLocalPart()).substring(20);
// Read attributes
ValueDescriptor descriptor = module.valueDescriptor(className);
StateDescriptor stateDescriptor = descriptor.state();
final Map<QualifiedName, Object> values = new HashMap<QualifiedName, Object>();
while (reader.hasMoreElementReaders()) {
MessageReader childReader = reader.getNextElementReader();
QName childName = childReader.getName();
QualifiedName childQualifiedName = QualifiedName.fromClass((Class) typeClass, childName.getLocalPart());
PropertyDescriptor propertyDescriptor = stateDescriptor.findPropertyModelByQualifiedName(childQualifiedName);
Type propertyType = propertyDescriptor.type();
AegisType type = getTypeMapping().getType(propertyType);
Object value = type.readObject(childReader, context);
values.put(childQualifiedName, value);
}
ValueBuilder<?> builder = module.newValueBuilderWithState((Class<?>) typeClass, new Function<PropertyDescriptor, Object>() {
@Override
public Object map(PropertyDescriptor descriptor1) {
return values.get(descriptor1.qualifiedName());
}
}, new Function<AssociationDescriptor, EntityReference>() {
@Override
public EntityReference map(AssociationDescriptor descriptor) {
Object value = values.get(descriptor.qualifiedName());
if (value == null)
return null;
else
return EntityReference.parseEntityReference(value.toString());
}
}, new Function<AssociationDescriptor, Iterable<EntityReference>>() {
@Override
public Iterable<EntityReference> map(AssociationDescriptor descriptor) {
Object value = values.get(descriptor.qualifiedName());
if (value == null)
return Iterables.empty();
else {
String[] ids = value.toString().split(",");
List<EntityReference> references = new ArrayList<EntityReference>();
for (int i = 0; i < ids.length; i++) {
String id = ids[i];
references.add(EntityReference.parseEntityReference(id));
}
return references;
}
}
});
return builder.newInstance();
}
use of org.qi4j.api.common.QualifiedName in project qi4j-sdk by Qi4j.
the class AbstractSQLStartup method extractManyAssociationQNames.
private void extractManyAssociationQNames(EntityDescriptor entityDesc, Map<QualifiedName, QNameInfo> extractedQNames, Set<QualifiedName> newQNames, Boolean setQNameTableNameToNull) {
for (AssociationDescriptor mAssoDesc : entityDesc.state().manyAssociations()) {
QualifiedName qName = mAssoDesc.qualifiedName();
if (SQLSkeletonUtil.isQueryable(mAssoDesc.accessor())) {
if (!extractedQNames.containsKey(qName)) {
//
extractedQNames.put(//
qName, //
QNameInfo.fromManyAssociation(//
qName, setQNameTableNameToNull ? null : (QNAME_TABLE_NAME_PREFIX + extractedQNames.size()), //
mAssoDesc));
newQNames.add(qName);
}
}
}
}
Aggregations