Search in sources :

Example 1 with WorkflowInfo

use of com.enonic.xp.content.WorkflowInfo in project xp by enonic.

the class ContentDataSerializer method extractWorkflowInfo.

private void extractWorkflowInfo(final PropertySet contentAsSet, final Content.Builder<?> builder) {
    final PropertySet workflowInfoSet = contentAsSet.getSet(WORKFLOW_INFO);
    final WorkflowInfo workflowInfo = workflowInfoSerializer.extract(workflowInfoSet);
    builder.workflowInfo(workflowInfo);
}
Also used : WorkflowInfo(com.enonic.xp.content.WorkflowInfo) PropertySet(com.enonic.xp.data.PropertySet)

Example 2 with WorkflowInfo

use of com.enonic.xp.content.WorkflowInfo in project xp by enonic.

the class ContentServiceImplTest_versions method version_workflow_info.

@Test
public void version_workflow_info() throws Exception {
    final Map<String, WorkflowCheckState> checks = Map.of("checkName1", WorkflowCheckState.APPROVED, "checkName2", WorkflowCheckState.PENDING);
    final WorkflowInfo workflowInfo = WorkflowInfo.create().state(WorkflowState.IN_PROGRESS).checks(checks).build();
    final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my test content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).workflowInfo(workflowInfo).build());
    final FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
    final ContentVersion contentVersion = versions.getContentVersions().iterator().next();
    final WorkflowInfo retrievedWorkflowInfo = contentVersion.getWorkflowInfo();
    assertEquals(WorkflowState.IN_PROGRESS, retrievedWorkflowInfo.getState());
    assertEquals(WorkflowCheckState.APPROVED, retrievedWorkflowInfo.getChecks().get("checkName1"));
    assertEquals(WorkflowCheckState.PENDING, retrievedWorkflowInfo.getChecks().get("checkName2"));
}
Also used : Content(com.enonic.xp.content.Content) ContentVersion(com.enonic.xp.content.ContentVersion) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) PropertyTree(com.enonic.xp.data.PropertyTree) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) WorkflowCheckState(com.enonic.xp.content.WorkflowCheckState) Test(org.junit.jupiter.api.Test)

Example 3 with WorkflowInfo

use of com.enonic.xp.content.WorkflowInfo in project xp by enonic.

the class ContentDataSerializerTest method create_propertyTree_populated_with_workflowInfo.

@Test
public void create_propertyTree_populated_with_workflowInfo() {
    final String check1Name = "myCheck1";
    final WorkflowCheckState check1State = WorkflowCheckState.APPROVED;
    final String check2Name = "myCheck2";
    final WorkflowCheckState check2State = WorkflowCheckState.PENDING;
    final WorkflowInfo workflowInfo = WorkflowInfo.create().state(WorkflowState.PENDING_APPROVAL).checks(Map.of(check1Name, check1State, check2Name, check2State)).build();
    final ContentDataSerializer contentDataSerializer = createContentDataSerializer();
    final CreateContentTranslatorParams params = CreateContentTranslatorParams.create().parent(ContentPath.ROOT).name("myContentName").contentData(new PropertyTree()).displayName("myDisplayName").type(ContentTypeName.codeMedia()).creator(PrincipalKey.ofAnonymous()).childOrder(ChildOrder.defaultOrder()).workflowInfo(workflowInfo).build();
    final PropertyTree data = contentDataSerializer.toCreateNodeData(params);
    final PropertySet workflowData = data.getSet(ContentPropertyNames.WORKFLOW_INFO);
    assertEquals(workflowInfo.getState().toString(), workflowData.getString(ContentPropertyNames.WORKFLOW_INFO_STATE));
    final PropertySet workflowChecks = workflowData.getPropertySet(ContentPropertyNames.WORKFLOW_INFO_CHECKS);
    assertEquals(check1State.toString(), workflowChecks.getString(check1Name));
    assertEquals(check2State.toString(), workflowChecks.getString(check2Name));
}
Also used : CreateContentTranslatorParams(com.enonic.xp.content.CreateContentTranslatorParams) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) WorkflowCheckState(com.enonic.xp.content.WorkflowCheckState) Test(org.junit.jupiter.api.Test)

Aggregations

WorkflowInfo (com.enonic.xp.content.WorkflowInfo)3 WorkflowCheckState (com.enonic.xp.content.WorkflowCheckState)2 PropertySet (com.enonic.xp.data.PropertySet)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 Test (org.junit.jupiter.api.Test)2 Content (com.enonic.xp.content.Content)1 ContentVersion (com.enonic.xp.content.ContentVersion)1 CreateContentTranslatorParams (com.enonic.xp.content.CreateContentTranslatorParams)1 FindContentVersionsResult (com.enonic.xp.content.FindContentVersionsResult)1