protected static Optional<SInstance> findDescendant(SIComposite instance, SType<?> type) { for (SInstance current : instance.getAllChildren()) { if (current.getType().getSuperType() == type) { return Optional.of(current); } } return Optional.empty(); }
public static List<SType<?>> getFields(SIComposite instance) { List<SType<?>> list = new ArrayList<>(); instance.getAllChildren().forEach(child -> addFieldToList(child.getType(), list)); return list; }
private static void toMap(Map<String, Content> value, SInstance instance) { if (instance instanceof SIComposite) { SIComposite item = (SIComposite) instance; for (SInstance i : item.getAllChildren()) { value.put(i.getName(), dehydrate(i)); } } }
private static void toMap(Map<String, Content> value, SInstance instancia) { if (instancia instanceof SIComposite) { SIComposite item = (SIComposite) instancia; for (SInstance i : item.getAllChildren()) { value.put(i.getName(), dehydrate(i)); } } }
composite.getAllChildren().forEach(inst -> attributeNames.add(inst.getType().getNameSimple())); Set<String> keySet = pojoDataMap.keySet(); for (String string : keySet) { for (SInstance child : composite.getAllChildren()) { Object object = pojoDataMap.get(child.getType().getNameSimple());
private SInstance getTupleKeyRef(SInstance instance, RelationalColumn column) { if (instance.getType().isComposite()) { for (SInstance field : ((SIComposite) instance).getAllChildren()) { String fieldTable = RelationalSQL.table(RelationalSQL.tableContext(field.getType())); String fieldColunm = RelationalSQL.column(field.getType()); if (fieldTable != null && fieldColunm != null && fieldTable.equalsIgnoreCase(column.getTable()) && fieldColunm.equalsIgnoreCase(column.getName())) { return RelationalSQL.tupleKeyRef(field); } } for (SInstance field : ((SIComposite) instance).getAllChildren()) { SInstance current = getTupleKeyRef(field, column); if (current != null) { return current; } } } return null; }
protected void updateInternal(@Nonnull SIComposite instance, SIComposite previousPersistedInstance, Integer inclusionActor) { for (SInstance field : instance.getAllChildren()) { if (RelationalSQL.isListWithTableBound(field.getType())) { updateFieldInternal(instance, previousPersistedInstance, inclusionActor, field); } } if (execScript(RelationalSQL.update(instance, previousPersistedInstance).toSQLScript()) == 0) { throw new SingularFormNotFoundException(FormKey.fromInstance(instance)); } }
public void delete(@Nonnull FormKey key) { INSTANCE mainInstance = load(key); mainInstance.getAllChildren().stream().filter(field -> RelationalSQL.isListWithTableBound(field.getType())) .forEach(field -> { SIList<SIComposite> listInstance = mainInstance.getFieldList(field.getType().getNameSimple(), SIComposite.class); for (SIComposite item : listInstance.getChildren()) { String manyToManyTable = manyToManyTable(item); if (manyToManyTable != null) { executeManyToManyDelete(mainInstance, item, manyToManyTable); } deleteInternal(item.getType(), FormKey.fromInstance(item)); } }); deleteInternal(createType(), key); }