Search in sources :

Example 1 with ImportLinkTypeContent

use of io.lumeer.engine.api.event.ImportLinkTypeContent in project engine by Lumeer.

the class LinkInstanceFacade method createLinkInstances.

public List<LinkInstance> createLinkInstances(final List<LinkInstance> linkInstances, final boolean sendIndividualNotifications) {
    if (linkInstances.size() > 0) {
        final String linkTypeId = linkInstances.get(0).getLinkTypeId();
        var linkType = checkCreateLinks(linkTypeId);
        checkLinkDocumentsExists(linkInstances);
        if (linkInstances.stream().anyMatch(linkInstance -> !linkInstance.getLinkTypeId().equals(linkTypeId))) {
            throw new BadFormatException("Cannot create link instances of multiple link types at once.");
        }
        final List<LinkInstance> storedLinkInstances = createLinkInstances(linkType, linkInstances, sendIndividualNotifications);
        if (importLinkTypeContentEvent != null) {
            importLinkTypeContentEvent.fire(new ImportLinkTypeContent(linkType));
        }
        return storedLinkInstances;
    }
    return linkInstances;
}
Also used : BadFormatException(io.lumeer.core.exception.BadFormatException) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) LinkInstance(io.lumeer.api.model.LinkInstance) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance) ImportLinkTypeContent(io.lumeer.engine.api.event.ImportLinkTypeContent)

Aggregations

LinkInstance (io.lumeer.api.model.LinkInstance)1 BadFormatException (io.lumeer.core.exception.BadFormatException)1 CreateLinkInstance (io.lumeer.engine.api.event.CreateLinkInstance)1 ImportLinkTypeContent (io.lumeer.engine.api.event.ImportLinkTypeContent)1 UpdateLinkInstance (io.lumeer.engine.api.event.UpdateLinkInstance)1