use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class TSMasterDataValueModel method getFieldValue.
public String getFieldValue(final String fieldName) {
final DtField dtField = dtDefinition.getField(fieldName);
final String camelCaseFieldName = StringUtil.constToLowerCamelCase(fieldName);
// ---
Assertion.when(dtField.isRequired()).check(() -> allFieldValues.containsKey(camelCaseFieldName), "Field '{0}' is required on '{1}' and no value was provided. Provided values '{2}'", fieldName, dtDefinition.getName(), allFieldValues);
// ---
return allFieldValues.getOrDefault(camelCaseFieldName, "null");
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class SqlMasterDataValueModel method getFieldValue.
public String getFieldValue(final String fieldName) {
final DtField dtField = dtDefinition.getField(fieldName);
final String camelCaseFieldName = StringUtil.constToLowerCamelCase(fieldName);
// ---
Assertion.when(dtField.isRequired()).check(() -> allFieldValues.containsKey(camelCaseFieldName), "Field '{0}' is required on '{1}' and no value was provided. Provided values '{2}'", fieldName, dtDefinition.getName(), allFieldValues);
// ---
return allFieldValues.getOrDefault(camelCaseFieldName, "null");
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class JpaDataStorePlugin method doFindAll.
private <E extends Entity> DtList<E> doFindAll(final ProcessAnalyticsTracer tracer, final DtDefinition dtDefinition, final DtListURIForNNAssociation dtcUri) {
final Class<E> resultClass = (Class<E>) ClassUtil.classForName(dtDefinition.getClassCanonicalName());
// PK de la DtList recherchée
final String idFieldName = dtDefinition.getIdField().get().getName();
// FK dans la table nn correspondant à la collection recherchée. (clé de jointure ).
final AssociationNNDefinition associationNNDefinition = dtcUri.getAssociationDefinition();
final String joinTableName = associationNNDefinition.getTableName();
final DtDefinition joinDtDefinition = AssociationUtil.getAssociationNode(associationNNDefinition, dtcUri.getRoleName()).getDtDefinition();
final DtField joinDtField = joinDtDefinition.getIdField().get();
// La condition s'applique sur l'autre noeud de la relation (par rapport à la collection attendue)
final AssociationNode associationNode = AssociationUtil.getAssociationNodeTarget(associationNNDefinition, dtcUri.getRoleName());
final DtField fkField = associationNode.getDtDefinition().getIdField().get();
final String fkFieldName = fkField.getName();
final String request = new StringBuilder(" select t.* from ").append(dtDefinition.getLocalName()).append(" t").append(" join ").append(joinTableName).append(" j on j.").append(joinDtField.getName()).append(" = t.").append(idFieldName).append(" where j.").append(fkFieldName).append(" = :").append(fkFieldName).toString();
final URI uri = dtcUri.getSource();
final Query q = getEntityManager().createNativeQuery(request, resultClass);
q.setParameter(fkFieldName, uri.getId());
final List<E> results = q.getResultList();
final DtList<E> dtc = new DtList<>(dtDefinition);
dtc.addAll(results);
tracer.setMeasure("nbSelectedRow", dtc.size());
return dtc;
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class SqlDataStorePlugin method readNullableForUpdate.
/**
* {@inheritDoc}
*/
@Override
public <E extends Entity> E readNullableForUpdate(final DtDefinition dtDefinition, final URI<?> uri) {
final String tableName = getTableName(dtDefinition);
final String taskName = TASK.TK_LOCK + "_" + tableName;
final String requestedFields = getRequestedFields(dtDefinition);
final DtField idField = getIdField(dtDefinition);
final String idFieldName = idField.getName();
final String request = sqlDialect.createSelectForUpdateQuery(tableName, requestedFields, idFieldName);
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request).addInRequired(idFieldName, idField.getDomain()).withOutOptional("dto", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + uri.getDefinition().getName() + "_DTO", Domain.class)).build();
final Task task = Task.builder(taskDefinition).addValue(idFieldName, uri.getId()).build();
return taskManager.execute(task).getResult();
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class SqlDataStorePlugin method findAll.
/**
* {@inheritDoc}
*/
@Override
public <E extends Entity> DtList<E> findAll(final DtDefinition dtDefinition, final DtListURIForSimpleAssociation dtcUri) {
Assertion.checkNotNull(dtDefinition);
Assertion.checkNotNull(dtcUri);
// ---
final DtField fkField = dtcUri.getAssociationDefinition().getFKField();
final Serializable value = dtcUri.getSource().getId();
return findByCriteria(dtDefinition, Criterions.isEqualTo(fkField::getName, value), null);
}
Aggregations