Java 类com.liferay.portal.kernel.util.ListUtil 实例源码

项目:ch-inofix-timetracker    文件:TimetrackerUtil.java   
public static List<TaskRecord> getTaskRecords(Hits hits) {

        List<Document> documents = ListUtil.toList(hits.getDocs());

        List<TaskRecord> taskRecords = new ArrayList<TaskRecord>();

        for (Document document : documents) {
            try {
                long taskRecordId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

                TaskRecord taskRecord = TaskRecordLocalServiceUtil.getTaskRecord(taskRecordId);
                taskRecords.add(taskRecord);

            } catch (Exception e) {

                if (_log.isErrorEnabled()) {
                    _log.error(e.getMessage());
                }
            }
        }

        return taskRecords;
    }
项目:ch-inofix-contact-manager    文件:ContactUtil.java   
public static List<Contact> getContacts(Hits hits) {

        List<Document> documents = ListUtil.toList(hits.getDocs());

        List<Contact> taskRecords = new ArrayList<Contact>();

        for (Document document : documents) {
            try {
                long taskRecordId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

                Contact taskRecord = ContactLocalServiceUtil.getContact(taskRecordId);
                taskRecords.add(taskRecord);

            } catch (Exception e) {

                if (_log.isErrorEnabled()) {
                    _log.error(e.getMessage());
                }
            }
        }

        return taskRecords;
    }
项目:com-liferay-apio-architect    文件:WebSiteServiceImpl.java   
@Override
public PageItems<WebSite> getPageItems(
    Pagination pagination, long companyId) {

    List<Group> groups = _groupLocalService.getGroups(companyId, 0, true);

    List<Group> paginationGroups = ListUtil.subList(
        groups, pagination.getStartPosition(), pagination.getEndPosition());

    Stream<Group> stream = paginationGroups.stream();

    List<WebSite> webSites = stream.map(
        WebSiteImpl::new
    ).collect(
        Collectors.toList()
    );

    int count = _groupLocalService.getGroupsCount(companyId, 0, true);

    return new PageItems<>(webSites, count);
}
项目:ch-inofix-data-manager    文件:MeasurementUtil.java   
public static List<Measurement> getMeasurements(Hits hits) {

        List<Document> documents = ListUtil.toList(hits.getDocs());

        List<Measurement> measurements = new ArrayList<Measurement>();

        for (Document document : documents) {
            try {
                long measurementId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

                Measurement measurement = MeasurementLocalServiceUtil.getMeasurement(measurementId);
                measurements.add(measurement);

            } catch (Exception e) {

                if (_log.isErrorEnabled()) {
                    _log.error(e.getMessage());
                }
            }
        }

        return measurements;
    }
项目:link-scanner    文件:LinkScannerUtil.java   
public static Set<String> getPortalURLPrefixes(ThemeDisplay themeDisplay)
    throws SystemException, PortalException {

    Set<String> portalURLPrefixes = new HashSet<String>();
    portalURLPrefixes.add(themeDisplay.getURLPortal());
    portalURLPrefixes.add("/");
    portalURLPrefixes.add(".");

    String[] portalURLPrefixesAdd = getPortalURLPrefixesAdd(themeDisplay.getCompanyId());

    if (Validator.isNotNull(portalURLPrefixesAdd)) {
        portalURLPrefixes.addAll(ListUtil.fromArray(portalURLPrefixesAdd));
    }

    return portalURLPrefixes;
}
项目:opencps-v2    文件:ServiceProcessUtils.java   
public static List<ProcessActionDataModel> mappingToProcessActionData(List<Document> documents) {

        List<ProcessActionDataModel> outputs = new ArrayList<ProcessActionDataModel>();

        for (Document doc : documents) {
            ProcessActionDataModel model = new ProcessActionDataModel();

            model.setProcessActionId(doc.get(Field.ENTRY_CLASS_PK));
            model.setActionCode(doc.get(ProcessActionTerm.ACTION_CODE));
            model.setActionName(doc.get(ProcessActionTerm.ACTION_NAME));
            model.setPreStepCode(doc.get(ProcessActionTerm.PRESTEP_CODE));
            model.setPreStepName(doc.get(ProcessActionTerm.PRESTEP_NAME));
            model.setPostStepCode(doc.get(ProcessActionTerm.POSTSTEP_CODE));
            model.setPostStepName(doc.get(ProcessActionTerm.POSTSTEP_NAME));
            model.setAutoEvent(doc.get(ProcessActionTerm.AUTO_EVENT));
            model.setPreCondition(doc.get(ProcessActionTerm.PRE_CONDITION));
            model.setAllowAssignUser(doc.get(ProcessActionTerm.ALLOW_ASSIGN_USER));
            model.setAssignUserId(doc.get(ProcessActionTerm.ASSIGN_USER_ID));
            model.setAssignUserName(doc.get(ProcessActionTerm.ASSIGN_USER_NAME));
            model.setRequestPayment(doc.get(ProcessActionTerm.REQUEST_PAYMENT));
            model.setPaymentFee(doc.get(ProcessActionTerm.PAYMENT_FEE));
            model.getCreateDossierFiles().addAll(ListUtil.toList(
                    StringUtil.split(doc.get(ProcessActionTerm.CREATE_DOSSIER_FILES).trim(), StringPool.COMMA)));
            model.getReturnDossierFiles().addAll(ListUtil.toList(
                    StringUtil.split(doc.get(ProcessActionTerm.RETURN_DOSSIER_FILES).trim(), StringPool.COMMA)));
            model.setMakeBriefNote(doc.get(ProcessActionTerm.MAKE_BRIEF_NOTE));
            model.setSyncActionCode(doc.get(ProcessActionTerm.SYNC_ACTION_CODE));
            model.setRollbackable(doc.get(ProcessActionTerm.ROLLBACKABLE));
            model.setCreateDossierNo(Boolean.getBoolean(doc.get(ProcessActionTerm.CREATE_DOSSIER_NO)));
            model.seteSignature(Boolean.getBoolean(doc.get(ProcessActionTerm.ESIGNATURE)));

            outputs.add(model);
        }

        return outputs;
    }
项目:edemocracia    文件:ResourceBlockLocalServiceImpl.java   
public void setIndividualScopePermissions(
        long companyId, long groupId, String name, long primKey,
        Map<Long, String[]> roleIdsToActionIds)
    throws PortalException, SystemException {

    boolean flushEnabled = PermissionThreadLocal.isFlushEnabled();

    PermissionThreadLocal.setIndexEnabled(false);

    try {
        PermissionedModel permissionedModel = getPermissionedModel(
            name, primKey);

        for (Map.Entry<Long, String[]> entry :
                roleIdsToActionIds.entrySet()) {

            long roleId = entry.getKey();
            String[] actionIds = entry.getValue();

            updateIndividualScopePermissions(
                companyId, groupId, name, permissionedModel, roleId,
                getActionIds(name, ListUtil.fromArray(actionIds)),
                ResourceBlockConstants.OPERATOR_SET);
        }
    }
    finally {
        PermissionThreadLocal.setIndexEnabled(flushEnabled);

        PermissionCacheUtil.clearCache();
    }
}
项目:liferay-microsite-manager    文件:MicroSiteUtil.java   
public static List<MicroSiteBean> subList(List<MicroSiteBean> list, Integer start, Integer end) {
    if (list != null) {
        return ListUtil.subList(list, start, end);
    } else {
        return new ArrayList<MicroSiteBean>();
    }
}
项目:liferay-voice-command    文件:SpeechUtil.java   
public static List<CommandBean> subList(List<CommandBean> list, Integer start, Integer end) {
    if (list != null) {
        return ListUtil.subList(list, start, end);
    } else {
        return new ArrayList<CommandBean>();
    }
}
项目:ch-inofix-timetracker    文件:BaseExportImportController.java   
protected void initXStream() {

        _xStream = new XStream(null, new XppDriver(), new ClassLoaderReference(
                XStreamConfiguratorRegistryUtil.getConfiguratorsClassLoader(XStream.class.getClassLoader())));

        _xStream.omitField(HashMap.class, "cache_bitmask");

        Set<XStreamConfigurator> xStreamConfigurators = XStreamConfiguratorRegistryUtil.getXStreamConfigurators();

        if (SetUtil.isEmpty(xStreamConfigurators)) {
            return;
        }

        List<String> allowedTypeNames = new ArrayList<>();

        for (XStreamConfigurator xStreamConfigurator : xStreamConfigurators) {
            List<XStreamAlias> xStreamAliases = xStreamConfigurator.getXStreamAliases();

            if (ListUtil.isNotEmpty(xStreamAliases)) {
                for (XStreamAlias xStreamAlias : xStreamAliases) {
                    _xStream.alias(xStreamAlias.getName(), xStreamAlias.getClazz());
                }
            }

            List<XStreamConverter> xStreamConverters = xStreamConfigurator.getXStreamConverters();

            if (ListUtil.isNotEmpty(xStreamConverters)) {
                for (XStreamConverter xStreamConverter : xStreamConverters) {
                    _xStream.registerConverter(new ConverterAdapter(xStreamConverter), XStream.PRIORITY_VERY_HIGH);
                }
            }

            List<XStreamType> xStreamTypes = xStreamConfigurator.getAllowedXStreamTypes();

            if (ListUtil.isNotEmpty(xStreamTypes)) {
                for (XStreamType xStreamType : xStreamTypes) {
                    allowedTypeNames.add(xStreamType.getTypeExpression());
                }
            }
        }

        // For default permissions, first wipe than add default

        _xStream.addPermission(NoTypePermission.NONE);

        // Add permissions

        _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        _xStream.addPermission(XStreamStagedModelTypeHierarchyPermission.STAGED_MODELS);

        _xStream.allowTypes(_XSTREAM_DEFAULT_ALLOWED_TYPES);

        _xStream.allowTypeHierarchy(List.class);
        _xStream.allowTypeHierarchy(Map.class);
        _xStream.allowTypeHierarchy(Timestamp.class);
        _xStream.allowTypeHierarchy(Set.class);

        _xStream.allowTypes(allowedTypeNames.toArray(new String[0]));

        _xStream.allowTypesByWildcard(new String[] { "com.thoughtworks.xstream.mapper.DynamicProxyMapper*" });
    }
项目:ch-inofix-timetracker    文件:TimetrackerXStreamConfigurator.java   
@Override
public List<XStreamAlias> getXStreamAliases() {
    return ListUtil.toList(_xStreamAliases);
}
项目:ch-inofix-contact-manager    文件:BaseExportImportController.java   
protected void initXStream() {

        _xStream = new XStream(null, new XppDriver(), new ClassLoaderReference(
                XStreamConfiguratorRegistryUtil.getConfiguratorsClassLoader(XStream.class.getClassLoader())));

        _xStream.omitField(HashMap.class, "cache_bitmask");

        Set<XStreamConfigurator> xStreamConfigurators = XStreamConfiguratorRegistryUtil.getXStreamConfigurators();

        if (SetUtil.isEmpty(xStreamConfigurators)) {
            return;
        }

        List<String> allowedTypeNames = new ArrayList<>();

        for (XStreamConfigurator xStreamConfigurator : xStreamConfigurators) {
            List<XStreamAlias> xStreamAliases = xStreamConfigurator.getXStreamAliases();

            if (ListUtil.isNotEmpty(xStreamAliases)) {
                for (XStreamAlias xStreamAlias : xStreamAliases) {
                    _xStream.alias(xStreamAlias.getName(), xStreamAlias.getClazz());
                }
            }

            List<XStreamConverter> xStreamConverters = xStreamConfigurator.getXStreamConverters();

            if (ListUtil.isNotEmpty(xStreamConverters)) {
                for (XStreamConverter xStreamConverter : xStreamConverters) {
                    _xStream.registerConverter(new ConverterAdapter(xStreamConverter), XStream.PRIORITY_VERY_HIGH);
                }
            }

            List<XStreamType> xStreamTypes = xStreamConfigurator.getAllowedXStreamTypes();

            if (ListUtil.isNotEmpty(xStreamTypes)) {
                for (XStreamType xStreamType : xStreamTypes) {
                    allowedTypeNames.add(xStreamType.getTypeExpression());
                }
            }
        }

        // For default permissions, first wipe than add default

        _xStream.addPermission(NoTypePermission.NONE);

        // Add permissions

        _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        _xStream.addPermission(XStreamStagedModelTypeHierarchyPermission.STAGED_MODELS);

        _xStream.allowTypes(_XSTREAM_DEFAULT_ALLOWED_TYPES);

        _xStream.allowTypeHierarchy(List.class);
        _xStream.allowTypeHierarchy(Map.class);
        _xStream.allowTypeHierarchy(Timestamp.class);
        _xStream.allowTypeHierarchy(Set.class);

        _xStream.allowTypes(allowedTypeNames.toArray(new String[0]));

        _xStream.allowTypesByWildcard(new String[] { "com.thoughtworks.xstream.mapper.DynamicProxyMapper*" });
    }
项目:ch-inofix-contact-manager    文件:ContactManagerXStreamConfigurator.java   
@Override
public List<XStreamAlias> getXStreamAliases() {
    return ListUtil.toList(_xStreamAliases);
}
项目:opencps-v2    文件:ProcessStepIndexer.java   
@Override
protected Document doGetDocument(ProcessStep object) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, object);

    // Indexer of audit fields
    document.addNumberSortable(Field.COMPANY_ID, object.getCompanyId());
    document.addNumberSortable(Field.GROUP_ID, object.getGroupId());
    document.addDateSortable(Field.MODIFIED_DATE, object.getCreateDate());
    document.addDateSortable(Field.CREATE_DATE, object.getModifiedDate());
    document.addNumberSortable(Field.USER_ID, object.getUserId());
    document.addKeywordSortable(Field.USER_NAME, String.valueOf(object.getUserName()));
    document.addKeywordSortable(Field.ENTRY_CLASS_NAME, CLASS_NAME);
    document.addNumberSortable(Field.ENTRY_CLASS_PK, object.getPrimaryKey());

    // add number fields
    document.addNumberSortable(ProcessStepTerm.DURATION_COUNT, object.getDurationCount());
    document.addNumberSortable(ProcessStepTerm.SERVICE_PROCESS_ID, object.getServiceProcessId());

    // add text fields
    document.addTextSortable(ProcessStepTerm.STEP_CODE, object.getStepCode());
    document.addTextSortable(ProcessStepTerm.STEP_NAME, object.getStepName());
    document.addTextSortable(ProcessStepTerm.SEQUENCE_NO, object.getSequenceNo());
    document.addTextSortable(ProcessStepTerm.DOSSIER_STATUS, object.getDossierStatus());

    document.addTextSortable(ProcessStepTerm.DOSSIER_STATUS_TEXT,
            getDictItemName(object.getGroupId(), DOSSIER_STATUS, object.getDossierStatus()));
    document.addTextSortable(ProcessStepTerm.DOSSIER_SUB_STATUS, object.getDossierSubStatus());
    document.addTextSortable(ProcessStepTerm.DOSSIER_SUB_STATUS_TEXT,
            getDictItemName(object.getGroupId(), DOSSIER_STATUS, object.getDossierSubStatus()));
    document.addTextSortable(ProcessStepTerm.CUSTOM_PROCESS_URL, object.getCustomProcessUrl());
    document.addTextSortable(ProcessStepTerm.STEP_INSTRUCTION, object.getStepInstruction());
    document.addTextSortable(ProcessStepTerm.BRIEF_NOTE, object.getBriefNote());
    document.addTextSortable(ProcessStepTerm.EDITABLE, Boolean.toString(object.getEditable()));

    // add extra fields (ProcessStepRole)
    List<ProcessStepRole> roles = ProcessStepRoleLocalServiceUtil.findByP_S_ID(object.getPrimaryKey());

    long[] roleArray = ListUtil.toLongArray(roles, ProcessStepRole.ROLE_ID_ACCESSOR);

    document.addNumber(ProcessStepRoleTerm.ROLE_ID, roleArray);

    return document;
}
项目:opencps-v2    文件:ServiceProcessIndexer.java   
@Override
protected Document doGetDocument(ServiceProcess object) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, object);

    // Indexer of audit fields
    document.addNumberSortable(Field.COMPANY_ID, object.getCompanyId());
    document.addNumberSortable(Field.GROUP_ID, object.getGroupId());
    document.addDateSortable(Field.MODIFIED_DATE, object.getCreateDate());
    document.addDateSortable(Field.CREATE_DATE, object.getModifiedDate());
    document.addNumberSortable(Field.USER_ID, object.getUserId());
    document.addKeywordSortable(Field.USER_NAME, String.valueOf(object.getUserName()));
    document.addKeywordSortable(Field.ENTRY_CLASS_NAME, CLASS_NAME);
    document.addNumberSortable(Field.ENTRY_CLASS_PK, object.getPrimaryKey());

    // add number fields
    document.addNumberSortable(ServiceProcessTerm.DURATION_COUNT, object.getDurationCount());
    document.addNumberSortable(ServiceProcessTerm.DURATION_UNIT, object.getDurationUnit());
    document.addNumberSortable(ServiceProcessTerm.COUNTER, object.getCounter());

    // add text fields
    document.addTextSortable(ServiceProcessTerm.PROCESS_NO, object.getProcessNo());
    document.addTextSortable(ServiceProcessTerm.PROCESS_NAME, object.getProcessName());
    document.addTextSortable(ServiceProcessTerm.DESCRIPTION, object.getDescription());
    document.addTextSortable(ServiceProcessTerm.DOSSIER_NO_PATTERN, object.getDossierNoPattern());
    document.addTextSortable(ServiceProcessTerm.DUEDATE_PATTERN, object.getDueDatePattern());
    document.addTextSortable(ServiceProcessTerm.SERVER_NO, object.getServerNo());

    ServerConfig server = ServerConfigLocalServiceUtil.getByCode(object.getServerNo());

    String serverName = StringPool.BLANK;

    if (Validator.isNotNull(server))
        serverName = server.getServerName();

    document.addTextSortable(ServiceProcessTerm.SERVER_NAME, serverName);

    document.addTextSortable(ServiceProcessTerm.GENERATE_DOSSIER_NO,
            Boolean.toString(object.getGenerateDossierNo()));
    document.addTextSortable(ServiceProcessTerm.GENERATE_DUE_DATE, Boolean.toString(object.getGenerateDueDate()));
    document.addTextSortable(ServiceProcessTerm.GENERATE_PASSWORD, Boolean.toString(object.getGeneratePassword()));
    document.addTextSortable(ServiceProcessTerm.DIRECT_NOTIFICATION,
            Boolean.toString(object.getDirectNotification()));

    // add extra fields (ServiceProcessRole)
    List<ServiceProcessRole> roles = ServiceProcessRoleLocalServiceUtil.findByS_P_ID(object.getPrimaryKey());

    long [] roleArray = ListUtil.toLongArray(roles, ServiceProcessRole.ROLE_ID_ACCESSOR);

    document.addNumber(ServiceProcessRoleTerm.ROLE_ID, roleArray);

    return document;
}
项目:opencps-v2    文件:ServiceProcessUtils.java   
public static ProcessActionReturnModel mappingToActionPOST(ProcessAction action) {

        ProcessActionReturnModel model = new ProcessActionReturnModel();

        model.setProcessActionId(String.valueOf(action.getPrimaryKey()));
        model.setActionCode(action.getActionCode());
        model.setActionName(action.getActionName());
        model.setPreStepCode(action.getPreStepCode());
        model.setPostStepCode(action.getPostStepCode());
        model.setAutoEvent(action.getAutoEvent());
        model.setPreCondition(action.getPreCondition());
        model.setAllowAssignUser(Boolean.toString(action.getAllowAssignUser()));
        model.setAssignUserId(String.valueOf(action.getAssignUserId()));

        String assignName = StringPool.BLANK;

        if (action.getAssignUserId() != 0) {
            User user = UserLocalServiceUtil.fetchUser(action.getAssignUserId());

            if (Validator.isNotNull(user)) {

                assignName = user.getFullName();
            }
        }

        model.setAssignUserName(assignName);
        model.setRequestPayment(Boolean.toString(action.getRequestPayment()));
        model.setPaymentFee(action.getPaymentFee());
        model.setMakeBriefNote(action.getMakeBriefNote());
        model.setSyncActionCode(action.getSyncActionCode());
        model.setRollbackable(Boolean.toString(action.getRollbackable()));

        model.getCreateDossierFiles()
                .addAll(ListUtil.toList(StringUtil.split(action.getCreateDossierFiles(), StringPool.COMMA)));

        model.getReturnDossierFiles()
                .addAll(ListUtil.toList(StringUtil.split(action.getReturnDossierFiles(), StringPool.COMMA)));

        model.setCreateDossierNo(action.getCreateDossierNo());
        model.seteSignature(action.getESignature());

        return model;
    }
项目:ch-inofix-data-manager    文件:BaseExportImportController.java   
protected void initXStream() {

        _xStream = new XStream(null, new XppDriver(), new ClassLoaderReference(
                XStreamConfiguratorRegistryUtil.getConfiguratorsClassLoader(XStream.class.getClassLoader())));

        _xStream.omitField(HashMap.class, "cache_bitmask");

        Set<XStreamConfigurator> xStreamConfigurators = XStreamConfiguratorRegistryUtil.getXStreamConfigurators();

        if (SetUtil.isEmpty(xStreamConfigurators)) {
            return;
        }

        List<String> allowedTypeNames = new ArrayList<>();

        for (XStreamConfigurator xStreamConfigurator : xStreamConfigurators) {
            List<XStreamAlias> xStreamAliases = xStreamConfigurator.getXStreamAliases();

            if (ListUtil.isNotEmpty(xStreamAliases)) {
                for (XStreamAlias xStreamAlias : xStreamAliases) {
                    _xStream.alias(xStreamAlias.getName(), xStreamAlias.getClazz());
                }
            }

            List<XStreamConverter> xStreamConverters = xStreamConfigurator.getXStreamConverters();

            if (ListUtil.isNotEmpty(xStreamConverters)) {
                for (XStreamConverter xStreamConverter : xStreamConverters) {
                    _xStream.registerConverter(new ConverterAdapter(xStreamConverter), XStream.PRIORITY_VERY_HIGH);
                }
            }

            List<XStreamType> xStreamTypes = xStreamConfigurator.getAllowedXStreamTypes();

            if (ListUtil.isNotEmpty(xStreamTypes)) {
                for (XStreamType xStreamType : xStreamTypes) {
                    allowedTypeNames.add(xStreamType.getTypeExpression());
                }
            }
        }

        // For default permissions, first wipe than add default

        _xStream.addPermission(NoTypePermission.NONE);

        // Add permissions

        _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        _xStream.addPermission(XStreamStagedModelTypeHierarchyPermission.STAGED_MODELS);

        _xStream.allowTypes(_XSTREAM_DEFAULT_ALLOWED_TYPES);

        _xStream.allowTypeHierarchy(List.class);
        _xStream.allowTypeHierarchy(Map.class);
        _xStream.allowTypeHierarchy(Timestamp.class);
        _xStream.allowTypeHierarchy(Set.class);

        _xStream.allowTypes(allowedTypeNames.toArray(new String[0]));

        _xStream.allowTypesByWildcard(new String[] { "com.thoughtworks.xstream.mapper.DynamicProxyMapper*" });
    }
项目:govapps    文件:ApplicationIndexer.java   
@Override
    protected Document doGetDocument(Object obj) throws Exception {
//      _log.debug("doGetDocument()");
        Application application = (Application) obj;
        long companyId = application.getCompanyId();
//        long groupId = getParentGroupId(application.getGroupId());
//        long scopeGroupId = application.getGroupId();
//        long groupId = 20102;
//        long scopeGroupId = 20102;

        long userId = application.getUserId();
        long resourcePrimKey = application.getPrimaryKey();
        String title = application.getName().toLowerCase();
        String content = "";
        String description = application.getDescription().toLowerCase();
        String regions = application.getRegionString().toLowerCase();
        String categoryString = application.getCategoryString().toLowerCase();
        String targetOS = application.getTargetOS().toLowerCase();
        content = content + " " + application.getRegionString().toLowerCase();
        content = content + " " + application.getCategoryString().toLowerCase();
        content = content + " " + application.getTargetOS().toLowerCase();
//        content = content + " " + application.getMinTargetOSVersion();


        Date modifiedDate = application.getModifiedDate();

       long[] assetCategoryIds = AssetCategoryLocalServiceUtil.getCategoryIds(Application.class.getName(), resourcePrimKey);

       List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(Application.class.getName(), resourcePrimKey);

       String[] assetCategoryNames = StringUtil.split(ListUtil.toString(categories, "name"));

       // EE lets you do this quicker: 

       // String[] assetCategoryNames =
       //     AssetCategoryLocalServiceUtil.getCategoryNames(
       //         Slogan.class.getName(), resourcePrimKey);

       String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(Application.class.getName(), resourcePrimKey);

        Document document = new DocumentImpl();

        document.addUID(PORTLET_ID, resourcePrimKey);

        document.addDate("modifiedDate", modifiedDate);
        document.addKeyword(Field.COMPANY_ID, companyId);
        document.addKeyword(Field.PORTLET_ID, PORTLET_ID);
//        document.addKeyword(Field.GROUP_ID, groupId);
//        document.addKeyword(Field.SCOPE_GROUP_ID, scopeGroupId);
        document.addKeyword(Field.USER_ID, userId);
        document.addText(Field.TITLE, title);
        document.addText(Field.CONTENT, content);
        document.addText(Field.DESCRIPTION, description);
        document.addText("regions", regions);
        document.addText("categoryString", categoryString);
        document.addText("targetOS", targetOS);
        document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds);
        document.addKeyword("assetCategoryNames", assetCategoryNames);
        //document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames);
        document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames);
        document.addKeyword(Field.ENTRY_CLASS_NAME, Application.class.getName());
        document.addKeyword(Field.ENTRY_CLASS_PK, resourcePrimKey);

        return document;
    }
项目:liferaylms-portlet    文件:ExecActivity.java   
@SuppressWarnings("unchecked")
public void moveQuestion(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long questionId = ParamUtil.getLong(actionRequest, "pageId"),
         prevQuestionId = ParamUtil.getLong(actionRequest, "prevPageId"),
         nextQuestionId = ParamUtil.getLong(actionRequest, "nextPageId");
    TestQuestion question = TestQuestionLocalServiceUtil.getTestQuestion(questionId);
    if(questionId>0){
        if(permissionChecker.hasPermission(themeDisplay.getScopeGroupId(), LearningActivity.class.getName(), questionId, ActionKeys.UPDATE)){
            TestQuestionLocalServiceUtil.moveQuestion(questionId, prevQuestionId, nextQuestionId);
        }
    }

    String orderByCol = ParamUtil.getString(actionRequest, "orderByCol");
       if(orderByCol==null || orderByCol=="")
           orderByCol = "weight";
       actionRequest.setAttribute("orderByCol", orderByCol);
       //Create an instance of BeanComparator telling it wich is the order column
       //Get the type of ordering, asc or desc
       String orderByType = ParamUtil.getString(actionRequest, "orderByType");
        if(orderByType==null || orderByType=="")
            orderByType = "asc";
        actionRequest.setAttribute("orderByType", orderByType);
        TestQuestion questions = TestQuestionLocalServiceUtil.getTestQuestion(questionId);
        List<TestQuestion> listaAux = TestQuestionLocalServiceUtil.getQuestions(questions.getActId());
        List<TestQuestion> listaTotal = new LinkedList<TestQuestion>();
        listaTotal = ListUtil.copy(listaAux);
        //Sort
           BeanComparator beanComparator = new BeanComparator(orderByCol);
        if(orderByType.equals("asc")){
            Collections.sort(listaTotal, beanComparator);
         } 
        else {
            Collections.sort(listaTotal, Collections.reverseOrder(beanComparator));
         }
    //Return the orderer list
    actionRequest.setAttribute("total", listaTotal.size());
    actionRequest.setAttribute("listaAux", listaTotal);
    actionResponse.setRenderParameter("actionEditingDetails", StringPool.TRUE);
    actionResponse.setRenderParameter("resId", Long.toString(question.getActId()));
    actionResponse.setRenderParameter("jsp", "/html/execactivity/test/admin/orderQuestions.jsp");
}
项目:liferaylms-portlet    文件:SurveyActivity.java   
@SuppressWarnings("unchecked")
public void moveQuestion(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long questionId = ParamUtil.getLong(actionRequest, "pageId"),
            prevQuestionId = ParamUtil.getLong(actionRequest, "prevPageId"),
            nextQuestionId = ParamUtil.getLong(actionRequest, "nextPageId");
    TestQuestion question = TestQuestionLocalServiceUtil.getTestQuestion(questionId);
    if(questionId>0){
        if(permissionChecker.hasPermission(themeDisplay.getScopeGroupId(), LearningActivity.class.getName(), questionId, ActionKeys.UPDATE)){
            TestQuestionLocalServiceUtil.moveQuestion(questionId, prevQuestionId, nextQuestionId);
        }
    }

    String orderByCol = ParamUtil.getString(actionRequest, "orderByCol");
    if(orderByCol==null || orderByCol=="")
        orderByCol = "weight";
    actionRequest.setAttribute("orderByCol", orderByCol);
    //Create an instance of BeanComparator telling it wich is the order column
    //Get the type of ordering, asc or desc
    String orderByType = ParamUtil.getString(actionRequest, "orderByType");
    if(orderByType==null || orderByType=="")
        orderByType = "asc";
    actionRequest.setAttribute("orderByType", orderByType);
    TestQuestion questions = TestQuestionLocalServiceUtil.getTestQuestion(questionId);
    List<TestQuestion> listaAux = TestQuestionLocalServiceUtil.getQuestions(questions.getActId());
    List<TestQuestion> listaTotal = new LinkedList<TestQuestion>();
    listaTotal = ListUtil.copy(listaAux);
    //Sort
    BeanComparator beanComparator = new BeanComparator(orderByCol);
    if(orderByType.equals("asc")){
        Collections.sort(listaTotal, beanComparator);
    } 
    else {
        Collections.sort(listaTotal, Collections.reverseOrder(beanComparator));
    }
    //Return the orderer list
    actionRequest.setAttribute("total", listaTotal.size());
    actionRequest.setAttribute("listaAux", listaTotal);
    actionResponse.setRenderParameter("actionEditingDetails", StringPool.TRUE);
    actionResponse.setRenderParameter("resId", Long.toString(question.getActId()));
    actionResponse.setRenderParameter("jsp", "/html/surveyactivity/admin/orderQuestions.jsp");
}
项目:liferay-webforms    文件:WebFormControlBean.java   
public DocumentModel getFiles() throws SystemException, NumberFormatException, PortalException {

        List<Document> documents = new ArrayList<Document>();

        List<DLFileEntry> dlFileEntries = new ArrayList<DLFileEntry>();
        OrderByComparator obc = new EntryNameComparator();

        if (this.selectedTreeFolder != null) {

            DLFolder dlFolder = DLFolderLocalServiceUtil.getDLFolder(new Long(this.selectedTreeFolder.getId()));
            dlFileEntries = ListUtil.copy(DLFileEntryLocalServiceUtil.getFileEntries(dlFolder.getGroupId(), dlFolder.getFolderId(), -1, -1, obc));

        } else {
            PortletRequest portletRequest = (PortletRequest) LiferayFacesContext.getCurrentInstance().getExternalContext().getRequest();
            ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

            dlFileEntries = ListUtil.copy(DLFileEntryLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(), new Long(0), -1, -1, obc));
        }

        for (DLFileEntry dlFileEntry : dlFileEntries) {
            documents.add(new Document("" + dlFileEntry.getFileEntryId(), dlFileEntry.getTitle(), dlFileEntry.getExtension()));
        }

        this.files = new DocumentModel(documents);

        return files;
    }