use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class SqlDataStorePlugin method createUpdateQuery.
/**
* Creates the update request.
*
* @param dtDefinition the dtDefinition
* @return the sql request
*/
private static String createUpdateQuery(final DtDefinition dtDefinition) {
final String tableName = getTableName(dtDefinition);
final DtField idField = getIdField(dtDefinition);
return new StringBuilder().append("update ").append(tableName).append(" set ").append(dtDefinition.getFields().stream().filter(dtField -> dtField.isPersistent() && !dtField.getType().isId()).map(dtField -> dtField.getName() + " =#DTO." + dtField.getName() + '#').collect(Collectors.joining(", "))).append(" where ").append(idField.getName()).append(" = #DTO.").append(idField.getName()).append('#').toString();
}
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 DtListURIForNNAssociation dtcUri) {
Assertion.checkNotNull(dtDefinition);
Assertion.checkNotNull(dtcUri);
// -----
final String tableName = getTableName(dtDefinition);
final String taskName = TASK.TK_SELECT + "_N_N_LIST_" + tableName + "_BY_URI";
// PK de la DtList recherchée
final String idFieldName = getIdField(dtDefinition).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 = getIdField(joinDtDefinition);
// 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 = getIdField(associationNode.getDtDefinition());
final String fkFieldName = fkField.getName();
final String request = new StringBuilder(" select t.* from ").append(tableName).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).append('#').toString();
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request).addInRequired(fkFieldName, fkField.getDomain()).withOutRequired("dtc", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + dtDefinition.getName() + "_DTC", Domain.class)).build();
final URI uri = dtcUri.getSource();
final Task task = Task.builder(taskDefinition).addValue(fkFieldName, uri.getId()).build();
return taskManager.execute(task).getResult();
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class AbstractDbFileStorePlugin method setIdValue.
/**
* @param dto DtObject
* @param value Pk value
*/
protected static void setIdValue(final DtObject dto, final Object value) {
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(dto);
final DtField idField = dtDefinition.getIdField().get();
idField.getDataAccessor().setValue(dto, value);
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class FsFileStorePlugin method setValue.
/**
* Fixe une valeur d'un champ d'un DtObject.
*
* @param dto DtObject
* @param field Nom du champs
* @param value Valeur
*/
private static void setValue(final DtObject dto, final DtoFields field, final Object value) {
final DtField dtField = DtObjectUtil.findDtDefinition(dto).getField(field.name());
dtField.getDataAccessor().setValue(dto, value);
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class CollectionsManagerTest method testFilterFullTextElision.
@Test
public void testFilterFullTextElision() {
final DtList<SmartItem> dtc = createItems();
final Collection<DtField> searchedDtFields = dtDefinitionItem.getFields();
final SmartItem mock1 = new SmartItem();
mock1.setId(seqId++);
mock1.setLabel("Agence de l'Ouest");
dtc.add(mock1);
final SmartItem mock2 = new SmartItem();
mock2.setId(seqId++);
mock2.setLabel("Hôpital et autres accents çava où àpied");
dtc.add(mock2);
Assert.assertTrue("La recherche ne supporte pas l'elision", filter(dtc, "ouest", 1000, searchedDtFields).size() == 1);
}
Aggregations