Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT.

Prototype

int STATUS_DRAFT

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT.

Click Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.service.test.DDMStructureLocalServiceTest.java

License:Open Source License

@Test
public void testSearchByAnyStatus() throws Exception {
    addStructure(0, _classNameId, null, StringUtil.randomString(), StringPool.BLANK, read("test-structure.xsd"),
            StorageType.JSON.getValue(), DDMStructureConstants.TYPE_DEFAULT, WorkflowConstants.STATUS_APPROVED);

    addStructure(0, _classNameId, null, StringUtil.randomString(), StringPool.BLANK, read("test-structure.xsd"),
            StorageType.JSON.getValue(), DDMStructureConstants.TYPE_DEFAULT, WorkflowConstants.STATUS_DRAFT);

    List<DDMStructure> structures = DDMStructureLocalServiceUtil.search(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, _classNameId, null, null, null,
            DDMStructureConstants.TYPE_DEFAULT, WorkflowConstants.STATUS_ANY, true, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS, null);/*from ww  w.j  a va2 s .co  m*/

    Assert.assertEquals(structures.toString(), 2, structures.size());
}

From source file:com.liferay.dynamic.data.mapping.service.test.DDMStructureLocalServiceTest.java

License:Open Source License

@Test
public void testSearchByDraftStatus() throws Exception {
    addStructure(0, _classNameId, null, StringUtil.randomString(), StringPool.BLANK, read("test-structure.xsd"),
            StorageType.JSON.getValue(), DDMStructureConstants.TYPE_DEFAULT, WorkflowConstants.STATUS_APPROVED);

    addStructure(0, _classNameId, null, StringUtil.randomString(), StringPool.BLANK, read("test-structure.xsd"),
            StorageType.JSON.getValue(), DDMStructureConstants.TYPE_DEFAULT, WorkflowConstants.STATUS_DRAFT);

    List<DDMStructure> structures = DDMStructureLocalServiceUtil.search(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, _classNameId, null, null, null,
            DDMStructureConstants.TYPE_DEFAULT, WorkflowConstants.STATUS_DRAFT, true, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS, null);//ww  w. j  a v  a 2 s.  c om

    Assert.assertEquals(structures.toString(), 1, structures.size());
}

From source file:com.liferay.dynamic.data.mapping.service.test.DDMTemplateLocalServiceTest.java

License:Open Source License

@Test
public void testSearchByAnyStatus() throws Exception {
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, "Event", null, WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, "Contact", null, WorkflowConstants.STATUS_DRAFT);

    List<DDMTemplate> templates = DDMTemplateLocalServiceUtil.search(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, null, null, _resourceClassNameId, null, null, null, null, null,
            WorkflowConstants.STATUS_ANY, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    Assert.assertEquals(templates.toString(), 2, templates.size());
}

From source file:com.liferay.dynamic.data.mapping.service.test.DDMTemplateLocalServiceTest.java

License:Open Source License

@Test
public void testSearchByDraftStatus() throws Exception {
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, "Event", null, WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, "Contact", null, WorkflowConstants.STATUS_DRAFT);

    List<DDMTemplate> templates = DDMTemplateLocalServiceUtil.search(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, null, null, _resourceClassNameId, null, null, null, null, null,
            WorkflowConstants.STATUS_DRAFT, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    Assert.assertEquals(templates.toString(), 1, templates.size());
}

From source file:com.liferay.dynamic.data.mapping.service.test.DDMTemplateServiceTest.java

License:Open Source License

@Test
public void testGetTemplatesByStructureAnyStatus() throws Exception {
    DDMStructure structure1 = addStructure(_recordSetClassNameId, StringUtil.randomString());
    DDMStructure structure2 = addStructure(_recordSetClassNameId, StringUtil.randomString());

    addDisplayTemplate(structure1.getPrimaryKey(), StringUtil.randomString(),
            WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(structure1.getPrimaryKey(), StringUtil.randomString(), WorkflowConstants.STATUS_DRAFT);
    addDisplayTemplate(structure2.getPrimaryKey(), StringUtil.randomString(), WorkflowConstants.STATUS_ANY);

    List<DDMTemplate> templates = DDMTemplateServiceUtil.getTemplates(TestPropsValues.getCompanyId(),
            group.getGroupId(), _structureClassNameId, structure1.getStructureId(), _recordSetClassNameId,
            WorkflowConstants.STATUS_ANY);

    Assert.assertEquals(templates.toString(), 2, templates.size());

    templates = DDMTemplateServiceUtil.getTemplates(TestPropsValues.getCompanyId(), group.getGroupId(),
            _structureClassNameId, structure2.getStructureId(), _recordSetClassNameId,
            WorkflowConstants.STATUS_ANY);

    Assert.assertEquals(templates.toString(), 1, templates.size());
}

From source file:com.liferay.dynamic.data.mapping.service.test.DDMTemplateServiceTest.java

License:Open Source License

@Test
public void testGetTemplatesByWorkflowStatus() throws Exception {
    DDMStructure structure = addStructure(_recordSetClassNameId, StringUtil.randomString());

    addDisplayTemplate(structure.getStructureId(), StringUtil.randomString(),
            WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(structure.getStructureId(), StringUtil.randomString(),
            WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(structure.getStructureId(), StringUtil.randomString(), WorkflowConstants.STATUS_DRAFT);

    List<DDMTemplate> templates = DDMTemplateServiceUtil.getTemplates(TestPropsValues.getCompanyId(),
            group.getGroupId(), _structureClassNameId, structure.getStructureId(), _recordSetClassNameId,
            DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY, WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(templates.toString(), 2, templates.size());

    templates = DDMTemplateServiceUtil.getTemplates(TestPropsValues.getCompanyId(), group.getGroupId(),
            _structureClassNameId, structure.getStructureId(), _recordSetClassNameId,
            DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY, WorkflowConstants.STATUS_DRAFT);

    Assert.assertEquals(templates.toString(), 1, templates.size());
}

From source file:com.liferay.exportimport.internal.model.listener.BackgroundTaskModelListener.java

License:Open Source License

@Override
public void onBeforeRemove(BackgroundTask backgroundTask) throws ModelListenerException {

    Map<String, Serializable> taskContextMap = backgroundTask.getTaskContextMap();

    long exportImportConfigurationId = MapUtil.getLong(taskContextMap, "exportImportConfigurationId");

    if (exportImportConfigurationId == 0) {
        return;/*from   www . j a  v a 2s.  com*/
    }

    try {
        ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService
                .fetchExportImportConfiguration(exportImportConfigurationId);

        if (exportImportConfiguration == null) {
            return;
        }

        if (exportImportConfiguration.getStatus() == WorkflowConstants.STATUS_DRAFT) {

            _exportImportConfigurationLocalService.deleteExportImportConfiguration(exportImportConfiguration);
        }
    } catch (Exception e) {
        throw new ModelListenerException("Unable to delete the process configuration for background " + "task "
                + backgroundTask.getBackgroundTaskId(), e);
    }
}

From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java

License:Open Source License

protected ServiceContext createServiceContext(Element element, String path, ClassedModel classedModel,
        Class<?> clazz) {//from  ww w.ja  va2s .c o  m

    ServiceContext serviceContext = new ServiceContext();

    // Theme display

    serviceContext.setCompanyId(getCompanyId());
    serviceContext.setScopeGroupId(getScopeGroupId());

    // Dates

    if (classedModel instanceof AuditedModel) {
        AuditedModel auditedModel = (AuditedModel) classedModel;

        serviceContext.setUserId(getUserId(auditedModel));
        serviceContext.setCreateDate(auditedModel.getCreateDate());
        serviceContext.setModifiedDate(auditedModel.getModifiedDate());
    }

    // Permissions

    if (!MapUtil.getBoolean(_parameterMap, PortletDataHandlerKeys.PERMISSIONS)) {

        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);
    }

    // Asset

    if (isResourceMain(classedModel)) {
        Serializable classPKObj = ExportImportClassedModelUtil.getPrimaryKeyObj(classedModel);

        long[] assetCategoryIds = getAssetCategoryIds(clazz, classPKObj);

        serviceContext.setAssetCategoryIds(assetCategoryIds);

        String[] assetTagNames = getAssetTagNames(clazz, classPKObj);

        serviceContext.setAssetTagNames(assetTagNames);
    }

    if (element != null) {
        Attribute assetPriorityAttribute = element.attribute("asset-entry-priority");

        if (assetPriorityAttribute != null) {
            double assetPriority = GetterUtil.getDouble(assetPriorityAttribute.getValue());

            serviceContext.setAssetPriority(assetPriority);
        }
    }

    // Expando

    String expandoPath = null;

    if (element != null) {
        expandoPath = element.attributeValue("expando-path");
    } else {
        expandoPath = ExportImportPathUtil.getExpandoPath(path);
    }

    if (Validator.isNotNull(expandoPath)) {
        try {
            Map<String, Serializable> expandoBridgeAttributes = (Map<String, Serializable>) getZipEntryAsObject(
                    expandoPath);

            if (expandoBridgeAttributes != null) {
                serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes);
            }
        } catch (Exception e) {
            if (_log.isDebugEnabled()) {
                _log.debug(e, e);
            }
        }
    }

    // Workflow

    if (classedModel instanceof WorkflowedModel) {
        WorkflowedModel workflowedModel = (WorkflowedModel) classedModel;

        if (workflowedModel.getStatus() == WorkflowConstants.STATUS_APPROVED) {

            serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);
        } else if (workflowedModel.getStatus() == WorkflowConstants.STATUS_DRAFT) {

            serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
        }
    }

    return serviceContext;
}

From source file:com.liferay.exportimport.test.util.lar.BaseExportImportTestCase.java

License:Open Source License

public void importLayouts(Map<String, String[]> parameterMap) throws Exception {

    User user = TestPropsValues.getUser();

    Map<String, Serializable> importLayoutSettingsMap = ExportImportConfigurationSettingsMapFactory
            .buildImportLayoutSettingsMap(user, importedGroup.getGroupId(), false, null, parameterMap);

    ExportImportConfiguration exportImportConfiguration = ExportImportConfigurationLocalServiceUtil
            .addExportImportConfiguration(user.getUserId(), importedGroup.getGroupId(), StringPool.BLANK,
                    StringPool.BLANK, ExportImportConfigurationConstants.TYPE_IMPORT_LAYOUT,
                    importLayoutSettingsMap, WorkflowConstants.STATUS_DRAFT, new ServiceContext());

    ExportImportServiceUtil.importLayouts(exportImportConfiguration, larFile);
}

From source file:com.liferay.exportimport.web.internal.messaging.DraftExportImportConfigurationMessageListener.java

License:Open Source License

protected void addCommonCriterions(DynamicQuery dynamicQuery) {
    Property typeProperty = PropertyFactoryUtil.forName("type");

    dynamicQuery.add(typeProperty.ne(ExportImportConfigurationConstants.TYPE_SCHEDULED_PUBLISH_LAYOUT_LOCAL));
    dynamicQuery.add(typeProperty.ne(ExportImportConfigurationConstants.TYPE_SCHEDULED_PUBLISH_LAYOUT_REMOTE));

    Property statusProperty = PropertyFactoryUtil.forName("status");

    dynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_DRAFT));
}