use of io.lumeer.api.model.function.Function in project engine by Lumeer.
the class FunctionFacadeIT method createLinkWithAttribute.
private LinkType createLinkWithAttribute(String name, List<String> collectionIds, String... attributeIds) {
List<Attribute> attributes = Arrays.stream(attributeIds).map(attributeId -> new Attribute(attributeId, attributeId, null, null, null, new Function("const lumeerko", "", "", 0, false), 1, null)).collect(Collectors.toList());
LinkType linkType = new LinkType(name, collectionIds, attributes, null, null, null);
return linkTypeDao.createLinkType(linkType);
}
use of io.lumeer.api.model.function.Function in project engine by Lumeer.
the class FunctionTask method process.
@Override
public void process(final TaskExecutor taskExecutor, final ChangesTracker changesTracker) {
if (daoContextSnapshot.getSelectedWorkspace() != null && daoContextSnapshot.getSelectedWorkspace().getOrganization().isPresent() && daoContextSnapshot.getSelectedWorkspace().getProject().isPresent()) {
log.info(String.format("Running function task on %s/%s > Resource '%s', Attribute '%s'.", daoContextSnapshot.getSelectedWorkspace().getOrganization().get().getCode(), daoContextSnapshot.getSelectedWorkspace().getProject().get().getCode(), collection != null ? collection.getName() : linkType.getName(), attribute.getName()));
}
if (documents != null && collection != null) {
getDocumentsWithData(collection, documents).forEach(document -> {
originalDocuments.put(document.getId(), new Document(document));
final FunctionTaskExecutor executor = new FunctionTaskExecutor(this, collection, document);
changesTracker.merge(executor.execute(taskExecutor));
});
} else if (linkType != null && linkInstances != null) {
getLinkInstancesWithData(linkType, linkInstances).forEach(linkInstance -> {
originalLinkInstances.put(linkInstance.getId(), new LinkInstance(linkInstance));
final FunctionTaskExecutor executor = new FunctionTaskExecutor(this, linkType, linkInstance);
changesTracker.merge(executor.execute(taskExecutor));
});
}
if (parent != null) {
parent.process(taskExecutor, changesTracker);
}
}
use of io.lumeer.api.model.function.Function in project engine by Lumeer.
the class AttributeCodec method convertFromDocument.
public static Attribute convertFromDocument(final Document document) {
String id = document.getString(ID);
String name = document.getString(NAME);
String description = document.getString(DESCRIPTION);
Constraint constraint = ConstraintCodec.convertFromDocument(document.get(CONSTRAINT, Document.class));
AttributeLock lock = AttributeLockCodec.convertFromDocument(document.get(LOCK, Document.class));
Function function = FunctionCodec.convertFromDocument(document.get(FUNCTION, Document.class));
Integer usageCount = document.getInteger(USAGE_COUNT);
Boolean suggestValues = document.getBoolean(SUGGEST_VALUES);
return new Attribute(id, name, description, constraint, lock, function, usageCount, suggestValues);
}
Aggregations