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

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

Introduction

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

Prototype

int STATUS_APPROVED

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

Click Source Link

Usage

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

License:Open Source License

@Test
public void testSearchCountByClassPKs() throws Exception {
    long classPK1 = RandomTestUtil.randomLong();

    addDisplayTemplate(_classNameId, classPK1, _resourceClassNameId, StringUtil.randomString(),
            StringUtil.randomString(), WorkflowConstants.STATUS_APPROVED);

    long classPK2 = RandomTestUtil.randomLong();

    addDisplayTemplate(_classNameId, classPK2, _resourceClassNameId, StringUtil.randomString(),
            StringUtil.randomString(), WorkflowConstants.STATUS_APPROVED);

    long classPK3 = RandomTestUtil.randomLong();

    addDisplayTemplate(_classNameId, classPK3, _resourceClassNameId, StringUtil.randomString(),
            StringUtil.randomString(), WorkflowConstants.STATUS_APPROVED);

    int count = DDMTemplateLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, null, new long[] { classPK1, classPK2, classPK3 },
            _resourceClassNameId, null, null, null, WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(3, count);//from  w ww . j a  v a  2 s.co  m
}

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

License:Open Source License

@Test
public void testSearchCountByKeywords() throws Exception {
    int initialCount = DDMTemplateLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(),
            group.getGroupId(), _classNameId, 0, 0, null, null, null, WorkflowConstants.STATUS_APPROVED);

    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, "Test Template", "Test Template",
            WorkflowConstants.STATUS_APPROVED);

    int count = DDMTemplateLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), group.getGroupId(),
            _classNameId, 0, _resourceClassNameId, "Test", null, null, WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(initialCount + 1, count);
}

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

License:Open Source License

@Test
public void testSearchCountByLanguage() throws Exception {
    String velocityLanguage = TemplateConstants.LANG_TYPE_VM;

    addTemplate(RandomTestUtil.randomLong(), RandomTestUtil.randomLong(), StringUtil.randomString(),
            StringPool.BLANK, StringPool.BLANK, velocityLanguage, getTestTemplateScript(velocityLanguage),
            WorkflowConstants.STATUS_APPROVED);
    addTemplate(RandomTestUtil.randomLong(), RandomTestUtil.randomLong(), StringUtil.randomString(),
            StringPool.BLANK, StringPool.BLANK, velocityLanguage, getTestTemplateScript(velocityLanguage),
            WorkflowConstants.STATUS_APPROVED);

    String freeMarkerLanguage = TemplateConstants.LANG_TYPE_FTL;

    addTemplate(RandomTestUtil.randomLong(), RandomTestUtil.randomLong(), StringUtil.randomString(),
            StringPool.BLANK, StringPool.BLANK, freeMarkerLanguage, getTestTemplateScript(freeMarkerLanguage),
            WorkflowConstants.STATUS_APPROVED);

    int count = DDMTemplateLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, null, null, _resourceClassNameId, null, null, null, null,
            TemplateConstants.LANG_TYPE_VM, WorkflowConstants.STATUS_APPROVED, true);

    Assert.assertEquals(2, count);/*from w ww. ja v  a2s.c  o  m*/
}

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

License:Open Source License

@Test
public void testSearchCountByResourceClassNameId() throws Exception {
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, StringUtil.randomString(),
            StringUtil.randomString(), WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, StringUtil.randomString(),
            StringUtil.randomString(), WorkflowConstants.STATUS_APPROVED);
    addDisplayTemplate(_classNameId, 0, _resourceClassNameId, StringUtil.randomString(),
            StringUtil.randomString(), WorkflowConstants.STATUS_APPROVED);

    int count = DDMTemplateLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(),
            new long[] { group.getGroupId() }, null, null, _resourceClassNameId, null, null, null,
            WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(3, count);/*from w w w.  j  av  a  2s  .  c  o  m*/
}

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.dynamic.data.mapping.test.util.DDMStructureTestHelper.java

License:Open Source License

public DDMStructure addStructure(long parentStructureId, long classNameId, String structureKey, String name,
        String description, DDMForm ddmForm, DDMFormLayout ddmFormLayout, String storageType, int type)
        throws Exception {

    return addStructure(parentStructureId, classNameId, structureKey, name, description, ddmForm, ddmFormLayout,
            storageType, type, WorkflowConstants.STATUS_APPROVED);
}

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

License:Open Source License

protected ServiceContext createServiceContext(Element element, String path, ClassedModel classedModel,
        Class<?> clazz) {//  w  w  w .ja  v a2  s  .  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.resources.importer.internal.util.FileSystemImporter.java

License:Open Source License

protected void addJournalArticles(String ddmStructureKey, String ddmTemplateKey, String fileName, long folderId,
        InputStream inputStream) throws Exception {

    String title = FileUtil.stripExtension(fileName);

    JSONObject assetJSONObject = _assetJSONObjectMap.get(fileName);

    Map<Locale, String> descriptionMap = null;

    boolean indexable = true;

    if (assetJSONObject != null) {
        String abstractSummary = assetJSONObject.getString("abstractSummary");

        descriptionMap = getMap(abstractSummary);

        indexable = GetterUtil.getBoolean(assetJSONObject.getString("indexable"), true);
    }/*from   w ww.j  a  v  a  2  s  .  c  o m*/

    String content = StringUtil.read(inputStream);

    content = replaceFileEntryURL(content);
    content = replaceLinksToLayouts(content);

    Locale articleDefaultLocale = LocaleUtil.fromLanguageId(LocalizationUtil.getDefaultLanguageId(content));

    boolean smallImage = false;
    String smallImageURL = StringPool.BLANK;

    if (assetJSONObject != null) {
        String smallImageFileName = assetJSONObject.getString("smallImage");

        if (Validator.isNotNull(smallImageFileName)) {
            smallImage = true;

            FileEntry fileEntry = _fileEntries.get(smallImageFileName);

            if (fileEntry != null) {
                smallImageURL = DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null,
                        StringPool.BLANK);
            }
        }
    }

    setServiceContext(fileName);

    String journalArticleId = getJournalId(fileName);

    JournalArticle journalArticle = journalArticleLocalService.fetchLatestArticle(groupId, journalArticleId,
            WorkflowConstants.STATUS_ANY);

    try {
        if (journalArticle == null) {
            journalArticle = journalArticleLocalService.addArticle(userId, groupId, folderId, 0, 0,
                    journalArticleId, false, JournalArticleConstants.VERSION_DEFAULT,
                    getMap(articleDefaultLocale, title), descriptionMap, content, ddmStructureKey,
                    ddmTemplateKey, StringPool.BLANK, 1, 1, 2010, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, 0, 0, 0,
                    true, indexable, smallImage, smallImageURL, null, new HashMap<String, byte[]>(),
                    StringPool.BLANK, serviceContext);
        } else {
            journalArticle = journalArticleLocalService.updateArticle(userId, groupId, folderId,
                    journalArticleId, journalArticle.getVersion(), getMap(articleDefaultLocale, title),
                    descriptionMap, content, ddmStructureKey, ddmTemplateKey, StringPool.BLANK, 1, 1, 2010, 0,
                    0, 0, 0, 0, 0, 0, true, 0, 0, 0, 0, 0, true, indexable, smallImage, smallImageURL, null,
                    new HashMap<String, byte[]>(), StringPool.BLANK, serviceContext);
        }

        journalArticleLocalService.updateStatus(userId, groupId, journalArticle.getArticleId(),
                journalArticle.getVersion(), WorkflowConstants.STATUS_APPROVED, StringPool.BLANK,
                new HashMap<String, Serializable>(), serviceContext);
    } catch (PortalException pe) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to import journal article " + fileName, pe);
        }

        throw pe;
    }

    addPrimaryKey(JournalArticle.class.getName(), journalArticle.getPrimaryKey());
}

From source file:com.liferay.faces.demos.bean.UsersModelBean.java

License:Open Source License

public List<SelectItem> getStatusSelectItems() {

    if (statusSelectItems == null) {
        LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
        statusSelectItems = new ArrayList<SelectItem>();
        statusSelectItems.add(// www.  j a  v a  2 s .co m
                new SelectItem(WorkflowConstants.STATUS_ANY, liferayFacesContext.getMessage("any-status")));
        statusSelectItems.add(
                new SelectItem(WorkflowConstants.STATUS_APPROVED, liferayFacesContext.getMessage("active")));
        statusSelectItems.add(
                new SelectItem(WorkflowConstants.STATUS_INACTIVE, liferayFacesContext.getMessage("inactive")));
    }

    return statusSelectItems;
}