Search in sources :

Example 1 with ConstraintManager

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;
    }
}
Also used : SelectedWorkspace(io.lumeer.api.SelectedWorkspace) Arrays(java.util.Arrays) TaskExecutor(io.lumeer.core.task.TaskExecutor) PrintTextOperation(io.lumeer.core.task.executor.operation.PrintTextOperation) CollectionUtil(io.lumeer.api.util.CollectionUtil) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) User(io.lumeer.api.model.User) FileAttachmentData(io.lumeer.core.task.executor.operation.data.FileAttachmentData) Operation(io.lumeer.core.task.executor.operation.Operation) TextPrintRequest(io.lumeer.core.task.executor.request.TextPrintRequest) StringUtils(org.apache.commons.lang3.StringUtils) UserMessageOperation(io.lumeer.core.task.executor.operation.UserMessageOperation) BigDecimal(java.math.BigDecimal) SmtpConfigurationBuilder(io.lumeer.core.task.executor.request.SmtpConfigurationBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceType(io.lumeer.api.model.ResourceType) Map(java.util.Map) AddLinkFileAttachmentOperation(io.lumeer.core.task.executor.operation.AddLinkFileAttachmentOperation) Collectors.toSet(java.util.stream.Collectors.toSet) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) DocumentOperation(io.lumeer.core.task.executor.operation.DocumentOperation) RoleType(io.lumeer.api.model.RoleType) View(io.lumeer.api.model.View) ViewPermissionsOperation(io.lumeer.core.task.executor.operation.ViewPermissionsOperation) DataDocument(io.lumeer.engine.api.data.DataDocument) Value(org.graalvm.polyglot.Value) DummySequenceOperation(io.lumeer.core.task.executor.operation.DummySequenceOperation) Document(io.lumeer.api.model.Document) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) LinkInstance(io.lumeer.api.model.LinkInstance) StandardCharsets(java.nio.charset.StandardCharsets) LinkType(io.lumeer.api.model.LinkType) Group(io.lumeer.api.model.Group) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) PrintAttributeOperation(io.lumeer.core.task.executor.operation.PrintAttributeOperation) SendSmtpEmailRequest(io.lumeer.core.task.executor.request.SendSmtpEmailRequest) List(java.util.List) SendEmailOperation(io.lumeer.core.task.executor.operation.SendEmailOperation) EmailSecurityType(io.lumeer.core.util.EmailSecurityType) Optional(java.util.Optional) Attribute(io.lumeer.api.model.Attribute) WithId(io.lumeer.api.model.common.WithId) SendSmtpEmailOperation(io.lumeer.core.task.executor.operation.SendSmtpEmailOperation) ChangesTracker(io.lumeer.core.task.executor.ChangesTracker) LongAdder(java.util.concurrent.atomic.LongAdder) LinkOperation(io.lumeer.core.task.executor.operation.LinkOperation) Engine(com.floreysoft.jmte.Engine) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DocumentCreationOperation(io.lumeer.core.task.executor.operation.DocumentCreationOperation) SendEmailRequest(io.lumeer.core.task.executor.request.SendEmailRequest) HashMap(java.util.HashMap) AllowedPermissions(io.lumeer.api.model.AllowedPermissions) ArrayList(java.util.ArrayList) NavigationOperation(io.lumeer.core.task.executor.operation.NavigationOperation) SearchQueryStem(io.lumeer.storage.api.query.SearchQueryStem) HashSet(java.util.HashSet) Language(io.lumeer.api.model.Language) LinkCreationOperation(io.lumeer.core.task.executor.operation.LinkCreationOperation) PrintRequest(io.lumeer.core.task.executor.request.PrintRequest) DocumentRemovalOperation(io.lumeer.core.task.executor.operation.DocumentRemovalOperation) Query(io.lumeer.api.model.Query) ResourceOperation(io.lumeer.core.task.executor.operation.ResourceOperation) ContextualTask(io.lumeer.core.task.ContextualTask) LinkTypeUtil(io.lumeer.api.util.LinkTypeUtil) Task(io.lumeer.core.task.Task) PermissionUtils(io.lumeer.api.util.PermissionUtils) IOException(java.io.IOException) UserMessageRequest(io.lumeer.core.task.executor.request.UserMessageRequest) NavigationRequest(io.lumeer.core.task.executor.request.NavigationRequest) SmtpConfiguration(io.lumeer.core.task.executor.request.SmtpConfiguration) SearchQuery(io.lumeer.storage.api.query.SearchQuery) AddDocumentFileAttachmentOperation(io.lumeer.core.task.executor.operation.AddDocumentFileAttachmentOperation) DocumentUtils(io.lumeer.core.util.DocumentUtils) FileAttachment(io.lumeer.api.model.FileAttachment) Collectors.toList(java.util.stream.Collectors.toList) ResourceVariable(io.lumeer.api.model.ResourceVariable) PdfCreator(io.lumeer.core.pdf.PdfCreator) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) Collection(io.lumeer.api.model.Collection) LinkInstance(io.lumeer.api.model.LinkInstance) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) IOException(java.io.IOException)

Example 2 with ConstraintManager

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;
    }
}
Also used : Arrays(java.util.Arrays) ZonedDateTime(java.time.ZonedDateTime) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Language(io.lumeer.api.model.Language) ParseException(org.json.simple.parser.ParseException) Map(java.util.Map) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) DateTimeException(java.time.DateTimeException) TemplateNotAvailableException(io.lumeer.core.exception.TemplateNotAvailableException) ProjectContent(io.lumeer.api.model.ProjectContent) JSONParser(org.json.simple.parser.JSONParser) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Date(java.sql.Date) Project(io.lumeer.api.model.Project) List(java.util.List) JSONObject(org.json.simple.JSONObject) Stream(java.util.stream.Stream) ObjectId(org.bson.types.ObjectId) BufferedReader(java.io.BufferedReader) TemplateCreated(io.lumeer.engine.api.event.TemplateCreated) HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 3 with ConstraintManager

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());
}
Also used : ConstraintManager(io.lumeer.core.constraint.ConstraintManager) CollectionChangeProcessor(io.lumeer.core.facade.detector.CollectionChangeProcessor) PurposeChangeProcessor(io.lumeer.core.facade.detector.PurposeChangeProcessor) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ConstraintManager (io.lumeer.core.constraint.ConstraintManager)3 Language (io.lumeer.api.model.Language)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Engine (com.floreysoft.jmte.Engine)1 SelectedWorkspace (io.lumeer.api.SelectedWorkspace)1 AllowedPermissions (io.lumeer.api.model.AllowedPermissions)1 Attribute (io.lumeer.api.model.Attribute)1 Collection (io.lumeer.api.model.Collection)1 Document (io.lumeer.api.model.Document)1 FileAttachment (io.lumeer.api.model.FileAttachment)1 Group (io.lumeer.api.model.Group)1 LinkInstance (io.lumeer.api.model.LinkInstance)1 LinkType (io.lumeer.api.model.LinkType)1 Project (io.lumeer.api.model.Project)1 ProjectContent (io.lumeer.api.model.ProjectContent)1 Query (io.lumeer.api.model.Query)1 ResourceType (io.lumeer.api.model.ResourceType)1 ResourceVariable (io.lumeer.api.model.ResourceVariable)1 RoleType (io.lumeer.api.model.RoleType)1 User (io.lumeer.api.model.User)1