Search in sources :

Example 1 with Builder

use of org.alfresco.repo.event.v1.model.NodeResource.Builder in project alfresco-repository by Alfresco.

the class ChildAssociationEventConsolidator method getRepoEvent.

/**
 * Builds and returns the {@link RepoEvent} instance.
 *
 * @param eventInfo the object holding the event information
 * @return the {@link RepoEvent} instance
 */
public RepoEvent<DataAttributes<ChildAssociationResource>> getRepoEvent(EventInfo eventInfo) {
    EventType eventType = getDerivedEvent();
    DataAttributes<ChildAssociationResource> eventData = buildEventData(eventInfo, resource);
    return RepoEvent.<DataAttributes<ChildAssociationResource>>builder().setId(eventInfo.getId()).setSource(eventInfo.getSource()).setTime(eventInfo.getTimestamp()).setType(eventType.getType()).setData(eventData).setDataschema(EventJSONSchema.getSchemaV1(eventType)).build();
}
Also used : EventType(org.alfresco.repo.event.v1.model.EventType) ChildAssociationResource(org.alfresco.repo.event.v1.model.ChildAssociationResource)

Example 2 with Builder

use of org.alfresco.repo.event.v1.model.NodeResource.Builder in project alfresco-repository by Alfresco.

the class PeerAssociationEventConsolidator method getRepoEvent.

/**
 * Builds and returns the {@link RepoEvent} instance.
 *
 * @param eventInfo the object holding the event information
 * @return the {@link RepoEvent} instance
 */
public RepoEvent<DataAttributes<PeerAssociationResource>> getRepoEvent(EventInfo eventInfo) {
    EventType eventType = getDerivedEvent();
    DataAttributes<PeerAssociationResource> eventData = buildEventData(eventInfo, resource);
    return RepoEvent.<DataAttributes<PeerAssociationResource>>builder().setId(eventInfo.getId()).setSource(eventInfo.getSource()).setTime(eventInfo.getTimestamp()).setType(eventType.getType()).setData(eventData).setDataschema(EventJSONSchema.getSchemaV1(eventType)).build();
}
Also used : PeerAssociationResource(org.alfresco.repo.event.v1.model.PeerAssociationResource) EventType(org.alfresco.repo.event.v1.model.EventType)

Example 3 with Builder

use of org.alfresco.repo.event.v1.model.NodeResource.Builder in project alfresco-repository by Alfresco.

the class EventConsolidator method getRepoEvent.

/**
 * Builds and returns the {@link RepoEvent} instance.
 *
 * @param eventInfo the object holding the event information
 * @return the {@link RepoEvent} instance
 */
public RepoEvent<DataAttributes<NodeResource>> getRepoEvent(EventInfo eventInfo) {
    NodeResource resource = buildNodeResource();
    EventType eventType = getDerivedEvent();
    DataAttributes<NodeResource> eventData = buildEventData(eventInfo, resource, eventType);
    return RepoEvent.<DataAttributes<NodeResource>>builder().setId(eventInfo.getId()).setSource(eventInfo.getSource()).setTime(eventInfo.getTimestamp()).setType(eventType.getType()).setData(eventData).setDataschema(EventJSONSchema.getSchemaV1(eventType)).build();
}
Also used : NodeResource(org.alfresco.repo.event.v1.model.NodeResource) EventType(org.alfresco.repo.event.v1.model.EventType)

Example 4 with Builder

use of org.alfresco.repo.event.v1.model.NodeResource.Builder in project alfresco-repository by Alfresco.

the class EventConsolidator method buildNodeResourceBeforeDelta.

protected NodeResource buildNodeResourceBeforeDelta(NodeResource after) {
    if (after == null) {
        return null;
    }
    Builder builder = NodeResource.builder();
    Map<QName, Serializable> changedPropsBefore = getBeforeMapChanges(propertiesBefore, propertiesAfter);
    if (!changedPropsBefore.isEmpty()) {
        // Set only the changed properties
        Map<String, Serializable> mappedProps = helper.mapToNodeProperties(changedPropsBefore);
        if (!mappedProps.isEmpty()) {
            builder.setProperties(mappedProps);
            resourceBeforeAllFieldsNull = false;
        }
        String name = (String) changedPropsBefore.get(ContentModel.PROP_NAME);
        if (name != null) {
            builder.setName(name);
            resourceBeforeAllFieldsNull = false;
        }
        ContentInfo contentInfo = helper.getContentInfo(changedPropsBefore);
        if (contentInfo != null) {
            builder.setContent(contentInfo);
            resourceBeforeAllFieldsNull = false;
        }
        UserInfo modifier = helper.getUserInfo((String) changedPropsBefore.get(ContentModel.PROP_MODIFIER));
        if (modifier != null) {
            builder.setModifiedByUser(modifier);
            resourceBeforeAllFieldsNull = false;
        }
        ZonedDateTime modifiedAt = helper.getZonedDateTime((Date) changedPropsBefore.get(ContentModel.PROP_MODIFIED));
        if (modifiedAt != null) {
            builder.setModifiedAt(modifiedAt);
            resourceBeforeAllFieldsNull = false;
        }
    }
    Set<String> aspectsBefore = getMappedAspectsBefore(after.getAspectNames());
    if (!aspectsBefore.isEmpty()) {
        builder.setAspectNames(aspectsBefore);
        resourceBeforeAllFieldsNull = false;
    }
    if (primaryHierarchyBefore != null && !primaryHierarchyBefore.isEmpty()) {
        builder.setPrimaryHierarchy(primaryHierarchyBefore);
        resourceBeforeAllFieldsNull = false;
    }
    if (nodeTypeBefore != null) {
        builder.setNodeType(helper.getQNamePrefixString(nodeTypeBefore));
        resourceBeforeAllFieldsNull = false;
    }
    return builder.build();
}
Also used : Serializable(java.io.Serializable) ContentInfo(org.alfresco.repo.event.v1.model.ContentInfo) ZonedDateTime(java.time.ZonedDateTime) QName(org.alfresco.service.namespace.QName) Builder(org.alfresco.repo.event.v1.model.NodeResource.Builder) UserInfo(org.alfresco.repo.event.v1.model.UserInfo)

Aggregations

EventType (org.alfresco.repo.event.v1.model.EventType)3 Serializable (java.io.Serializable)1 ZonedDateTime (java.time.ZonedDateTime)1 ChildAssociationResource (org.alfresco.repo.event.v1.model.ChildAssociationResource)1 ContentInfo (org.alfresco.repo.event.v1.model.ContentInfo)1 NodeResource (org.alfresco.repo.event.v1.model.NodeResource)1 Builder (org.alfresco.repo.event.v1.model.NodeResource.Builder)1 PeerAssociationResource (org.alfresco.repo.event.v1.model.PeerAssociationResource)1 UserInfo (org.alfresco.repo.event.v1.model.UserInfo)1 QName (org.alfresco.service.namespace.QName)1