use of io.lumeer.core.constraint.ConstraintManager in project engine by Lumeer.
the class LumeerBridge method getSiblings.
@SuppressWarnings("unused")
public List<DocumentBridge> getSiblings(final String linkTypeId, final DocumentBridge sourceDocument) {
try {
final String sourceDocumentId = sourceDocument.getDocument().getId();
final List<LinkInstance> counterparts = getLinkInstances(sourceDocumentId, linkTypeId);
if (!counterparts.isEmpty()) {
final Set<String> counterpartIds = counterparts.stream().map(l -> l.getDocumentIds().get(0).equals(sourceDocumentId) ? l.getDocumentIds().get(1) : l.getDocumentIds().get(0)).collect(toSet());
final List<LinkInstance> instances = getLinkInstances(counterpartIds, linkTypeId);
final Set<String> documentIds = instances.stream().flatMap(l -> l.getDocumentIds().stream()).collect(toSet());
documentIds.removeAll(counterpartIds);
documentIds.remove(sourceDocumentId);
if (!documentIds.isEmpty()) {
final Collection collection = task.getDaoContextSnapshot().getCollectionDao().getCollectionById(sourceDocument.getDocument().getCollectionId());
final List<Document> documents = DocumentUtils.loadDocumentsWithData(task.getDaoContextSnapshot(), collection, documentIds, constraintManager, true);
return documents.stream().map(DocumentBridge::new).collect(toList());
}
}
return List.of();
} catch (Exception e) {
cause = e;
throw e;
}
}
use of io.lumeer.core.constraint.ConstraintManager in project engine by Lumeer.
the class TemplateParser method translateConfig.
public Object translateConfig(final Object config, final ConstraintManager constraintManager) {
if (config instanceof String) {
return translateString((String) config, constraintManager);
} else if (config instanceof List) {
var newList = new ArrayList();
((List) config).forEach(value -> {
newList.add(translateConfig(value, constraintManager));
});
return newList;
} else if (config instanceof Set) {
var newSet = new HashSet();
((Set) config).forEach(value -> {
newSet.add(translateConfig(value, constraintManager));
});
return newSet;
} else if (config instanceof Map) {
var newMap = new HashMap<>();
((Map) config).forEach((k, v) -> {
newMap.put(translateConfig(k, constraintManager), translateConfig(v, constraintManager));
});
return newMap;
} else {
return config;
}
}
use of io.lumeer.core.constraint.ConstraintManager in project engine by Lumeer.
the class DelayedActionFacade method init.
@PostConstruct
public void init() {
final ConstraintManager constraintManager = ConstraintManager.getInstance(configurationProducer);
collectionChangeProcessor = new CollectionChangeProcessor(delayedActionDao, collectionDao, selectedWorkspace);
purposeChangeProcessor = new PurposeChangeProcessor(delayedActionDao, userDao, groupDao, selectedWorkspace, authenticatedUser.getCurrentUser(), requestDataKeeper, constraintManager, configurationProducer.getEnvironment());
}
Aggregations