use of org.qi4j.api.composite.Composite in project qi4j-sdk by Qi4j.
the class ModuleInstance method newValueBuilderWithPrototype.
@Override
@SuppressWarnings("unchecked")
public <T> ValueBuilder<T> newValueBuilderWithPrototype(T prototype) {
NullArgumentException.validateNotNull("prototype", prototype);
ValueInstance valueInstance = ValueInstance.valueInstanceOf((ValueComposite) prototype);
Class<Composite> valueType = (Class<Composite>) first(valueInstance.types());
ModelModule<ValueModel> modelModule = typeLookup.lookupValueModel(valueType);
if (modelModule == null) {
throw new NoSuchValueException(valueType.getName(), name());
}
return new ValueBuilderWithPrototype<>(modelModule, this, prototype);
}
use of org.qi4j.api.composite.Composite in project qi4j-sdk by Qi4j.
the class AbstractNamedQueryTest method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
super.assemble(module);
new EntityTestAssembler().assemble(module);
String[] query = queryStrings();
for (int i = 0; i < query.length; i++) {
String queryName = String.format("script%02d", i + 1);
if (query[i].length() != 0) {
Specification<Composite> expression = createNamedQueryDescriptor(queryName, query[i]);
queries.put(queryName, expression);
}
}
}
use of org.qi4j.api.composite.Composite in project qi4j-sdk by Qi4j.
the class EntityStateSerializer method serializeValueComposite.
private void serializeValueComposite(Resource subject, URI predicate, ValueComposite value, ValueType valueType, Graph graph, String baseUri, boolean includeNonQueryable) {
final ValueFactory valueFactory = graph.getValueFactory();
BNode collection = valueFactory.createBNode();
graph.add(subject, predicate, collection);
for (PropertyDescriptor persistentProperty : ((ValueCompositeType) valueType).properties()) {
Object propertyValue = Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map((Composite) value).state().propertyFor(persistentProperty.accessor()).get();
if (propertyValue == null) {
// Skip null values
continue;
}
ValueType type = persistentProperty.valueType();
if (type instanceof ValueCompositeType) {
URI pred = valueFactory.createURI(baseUri, persistentProperty.qualifiedName().name());
serializeValueComposite(collection, pred, (ValueComposite) propertyValue, type, graph, baseUri + persistentProperty.qualifiedName().name() + "/", includeNonQueryable);
} else {
serializeProperty(persistentProperty, propertyValue, collection, graph, includeNonQueryable);
}
}
}
use of org.qi4j.api.composite.Composite in project qi4j-sdk by Qi4j.
the class DebugConcern method debug.
@Override
public void debug(int priority, String message) {
System.out.println("L:" + composite);
if (loggingService == null) {
return;
}
if (priority >= loggingService.debugLevel()) {
Composite derefed = api.dereference(composite);
loggingService.debug(derefed, message);
}
}
use of org.qi4j.api.composite.Composite in project qi4j-sdk by Qi4j.
the class CompositeModel method newProxy.
public Composite newProxy(InvocationHandler invocationHandler) throws ConstructionException {
Class<?> mainType = first(types());
if (mainType.isInterface()) {
try {
return Composite.class.cast(proxyConstructor.newInstance(invocationHandler));
} catch (Exception e) {
throw new ConstructionException(e);
}
} else {
try {
Object[] args = new Object[proxyConstructor.getParameterTypes().length];
Composite composite = Composite.class.cast(proxyConstructor.newInstance(args));
proxyClass.getField("_instance").set(composite, invocationHandler);
return composite;
} catch (Exception e) {
throw new ConstructionException(e);
}
}
}
Aggregations