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

项目:opencps-v2    文件:DeliverableTypesManagementImpl.java   
public Response updateDeliverableTypeMappingData(HttpServletRequest request, HttpHeaders header, Company company,
        Locale locale, User user, ServiceContext serviceContext, long deliverableTypeId, String mappingData) {
    // TODO Update FormReport of Deliverable Type
    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        DeliverableTypesActions action = new DeliverableTypesActionsImpl();

        DeliverableType deliverableType = action.updateDeliverableTypeMappingData(groupId, deliverableTypeId,
                mappingData, serviceContext);

        DeliverableTypeDetailModel result = DeliverableTypesUtils.mappingToDeliverableTypesModel(deliverableType);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        return processException(e);
    }
}
项目:ch-inofix-timetracker    文件:TaskRecordIndexer.java   
@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    boolean advancedSearch = GetterUtil.getBoolean(searchContext.getAttribute("advancedSearch"), false);

    addSearchTerm(searchQuery, searchContext, "description", false);
    if (!advancedSearch) {
        addSearchTerm(searchQuery, searchContext, "workPackage", true);
    }

    // TODO: add ticketURL

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }
    }
}
项目: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    文件:ContactDisplayTerms.java   
public ContactDisplayTerms(PortletRequest portletRequest) {
    super(portletRequest);

    company = ParamUtil.getString(portletRequest, COMPANY);
    contactId = ParamUtil.getString(portletRequest, CONTACT_ID);
    createDate = ParamUtil.getString(portletRequest, CREATE_DATE);
    email = ParamUtil.getString(portletRequest, EMAIL);
    fax = ParamUtil.getString(portletRequest, FAX);
    fullName = ParamUtil.getString(portletRequest, FULL_NAME);
    // TODO: add default IMPP
    name = ParamUtil.getString(portletRequest, NAME);
    modifiedDate = ParamUtil.getString(portletRequest, MODIFIED_DATE);
    String statusString = ParamUtil.getString(portletRequest, STATUS);

    if (Validator.isNotNull(statusString)) {
        status = GetterUtil.getInteger(statusString);
    }

    phone = ParamUtil.getString(portletRequest, PHONE);
    userName = ParamUtil.getString(portletRequest, USER_NAME);
}
项目:ch-inofix-data-manager    文件:MeasurementDisplayTerms.java   
public MeasurementDisplayTerms(PortletRequest portletRequest) {

        super(portletRequest);

        createDate = ParamUtil.getString(portletRequest, CREATE_DATE);
        data = ParamUtil.getString(portletRequest, DATA);
        from = ParamUtil.getLong(portletRequest, FROM);
        groupId = ParamUtil.getLong(portletRequest, GROUP_ID);
        id = ParamUtil.getString(portletRequest, ID);
        measurementId = ParamUtil.getLong(portletRequest, MEASUREMENT_ID);
        modifiedDate = ParamUtil.getString(portletRequest, MODIFIED_DATE);
        name = ParamUtil.getString(portletRequest, NAME);
        String statusString = ParamUtil.getString(portletRequest, STATUS);

        if (Validator.isNotNull(statusString)) {
            status = GetterUtil.getInteger(statusString);
        }
        until = ParamUtil.getLong(portletRequest, UNTIL);
        userName = ParamUtil.getString(portletRequest, USER_NAME);
    }
项目:liferay-gsearch    文件:WildcardQueryBuilderImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public BooleanQuery buildSplittedQuery(
    JSONObject configurationObject, QueryParams queryParams)
    throws Exception {

    BooleanQuery query = new BooleanQueryImpl();

    String keywordSplitter = configurationObject.getString("keywordSplitter");

    String [] keywords = queryParams.getKeywords().split(keywordSplitter);

    for (String keyword : keywords) {
        WildcardQuery q = buildClause(configurationObject, keyword);
        query.add(q, BooleanClauseOccur.SHOULD);
    }

    float boost = GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);
    query.setBoost(boost);

    return query;
}
项目:opencps-v2    文件:RegistrationTemplatesManagementImpl.java   
@Override
public Response getFormReportByRegistrationTemplateId(HttpServletRequest request, HttpHeaders header,
        Company company, Locale locale, User user, ServiceContext serviceContext, long registrationTemplateId) {
    // TODO Get FormReport of RegistrationTemplates
    BackendAuth auth = new BackendAuthImpl();

    RegistrationTemplateFormReportInputUpdateModel result = new RegistrationTemplateFormReportInputUpdateModel();

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }
        long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
        RegistrationTemplates registrationTemplate = RegistrationTemplatesLocalServiceUtil
                .getRegTempbyRegId(groupId, registrationTemplateId);

        result.setFormReport(registrationTemplate.getFormReport());

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:opencps-v2    文件:ServiceProcessUtils.java   
public static List<RoleDataModel> mappingToStepRole(List<ProcessStepRole> stepRoles) {
    List<RoleDataModel> outputs = new ArrayList<RoleDataModel>();

    for (ProcessStepRole role : stepRoles) {

        RoleDataModel model = new RoleDataModel();

        model.setRoleId(GetterUtil.getInteger(role.getRoleId()));
        model.setRoleName(_getRoleName(role.getRoleId()));
        model.setCondition(role.getCondition());
        model.setModerator(Boolean.toString(role.getModerator()));

        outputs.add(model);
    }

    return outputs;
}
项目:opencps-v2    文件:DossierTemplateUtils.java   
public static List<DossierTemplateDataModel> mappingToDossierTemplateList(List<Document> documents) {
    List<DossierTemplateDataModel> outputs = new ArrayList<DossierTemplateDataModel>();

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

        model.setDossierTemplateId(GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)));
        model.setCreateDate(doc.get(Field.CREATE_DATE));
        model.setModifiedDate(doc.get(Field.MODIFIED_DATE));
        model.setTemplateName(doc.get(DossierTemplateTerm.TEMPLATE_NAME));
        model.setTemplateNo(doc.get(DossierTemplateTerm.TEMPLATE_NO));
        model.setDescription(doc.get(DossierTemplateTerm.DESCRIPTION));

        outputs.add(model);
    }

    return outputs;
}
项目:opencps-v2    文件:RegistrationTemplatesManagementImpl.java   
@Override
public Response getSampleDataByRegistrationTemplateId(HttpServletRequest request, HttpHeaders header,
        Company company, Locale locale, User user, ServiceContext serviceContext, long registrationTemplateId) {
    // TODO Get SampleData of RegistrationTemplates
    BackendAuth auth = new BackendAuthImpl();

    RegistrationTemplateSampleDataInputUpdateModel result = new RegistrationTemplateSampleDataInputUpdateModel();

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }
        long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
        RegistrationTemplates registrationTemplate = RegistrationTemplatesLocalServiceUtil
                .getRegTempbyRegId(groupId, registrationTemplateId);

        result.setSampleData(registrationTemplate.getSampleData());

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:opencps-v2    文件:RegistrationTemplatesUtils.java   
public static RegistrationTemplateDetailModel mappingToRegistrationTemplateModel(
        RegistrationTemplates registrationTemplates) {

    if (registrationTemplates == null) {
        return null;
    }
    long registrationTemplateId = GetterUtil.getLong(registrationTemplates.getRegistrationTemplateId());
    RegistrationTemplateDetailModel model = new RegistrationTemplateDetailModel();

    model.setRegistrationTemplateId(registrationTemplateId);
    model.setGovAgencyCode(registrationTemplates.getGovAgencyCode());
    model.setFormName(registrationTemplates.getFormName());
    model.setFormNo(registrationTemplates.getFormNo());
    model.setMultiple(registrationTemplates.getMultiple());

    return model;
}
项目:opencps-v2    文件:RegistrationTemplatesUtils.java   
public static List<DossierLogSearchIdModel> mappingToDeliverableTypesSearchByIdResultsModel(
        List<Document> documents) {

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

    for (Document document : documents) {

        DossierLogSearchIdModel model = new DossierLogSearchIdModel();

        long dossierLogId = GetterUtil.getLong(document.get("entryClassPK"));
        // int notificationType =
        // GetterUtil.getInteger(document.get(DossierLogTerm.NOTIFICATION_TYPE));

        model.setDossierLogId(dossierLogId);
        model.setAuthor(document.get(DossierLogTerm.AUTHOR));
        model.setContent(document.get(DossierLogTerm.CONTENT));
        model.setCreateDate(document.get(DossierLogTerm.CREATE_DATE));
        model.setNotificationType(document.get(DossierLogTerm.NOTIFICATION_TYPE));
        model.setPayload(document.get(DossierLogTerm.PAYLOAD));

        outputs.add(model);
    }

    return outputs;

}
项目:opencps-v2    文件:RegistrationFormManagementImpl.java   
@Override
public Response getformdatabyRegidRefid(HttpServletRequest request, HttpHeaders header, Company company,
        Locale locale, User user, ServiceContext serviceContext, long registrationId, String referenceUid)
        throws PortalException {
    BackendAuth auth = new BackendAuthImpl();
    try {
        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }
        long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
        RegistrationForm registrationForm = RegistrationFormLocalServiceUtil.findFormbyRegidRefid(groupId,
                registrationId, referenceUid);

        return Response.status(200).entity(registrationForm.getFormData()).build();

    } catch (Exception e) {
        return processException(e);
    }
}
项目:opencps-v2    文件:ServiceInfoManagementImpl.java   
@Override
public Response getStatisticByAgency(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext) {
    ServiceInfoActions actions = new ServiceInfoActionsImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    JSONObject results = JSONFactoryUtil.createJSONObject();

    try {
        results = actions.getStatisticByAdministration(serviceContext, groupId);

        _log.info(results);

        return Response.status(200).entity(JSONFactoryUtil.looseSerialize(results)).build();

    } catch (Exception e) {
        ErrorMsg error = new ErrorMsg();

            error.setMessage("Forbidden.");
            error.setCode(HttpURLConnection.HTTP_FORBIDDEN);
            error.setDescription("Forbidden.");

            return Response.status(HttpURLConnection.HTTP_FORBIDDEN).entity(error).build();
    }
}
项目:opencps-v2    文件:RegistrationTemplatesManagementImpl.java   
@Override
public Response getRegistrationTemplatebyId(HttpServletRequest request, HttpHeaders header, Company company,
        Locale locale, User user, ServiceContext serviceContext, String id) {
    // TODO Get RegistrationTemplates by Id
    BackendAuth auth = new BackendAuthImpl();
    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        RegistrationTemplates registrationTemplates = RegistrationTemplatesLocalServiceUtil
                .getRegistrationTemplatebyId(groupId, id);

        RegistrationTemplateDetailModel result = RegistrationTemplatesUtils
                .mappingToRegistrationTemplateModel(registrationTemplates);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:opencps-v2    文件:DossierLogManagementImpl.java   
@Override
public Response getDossierLogs(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, DossierLogSearchModel query) {

    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {

        // if (!auth.isAuth(serviceContext)) {
        // throw new UnauthenticationException();
        // }

        DossierLogResultsModel results = new DossierLogResultsModel();

        DossierLogActions action = new DossierLogActionsImpl();

        JSONObject dossierLogJsonObject = action.getDossierLogs(groupId, query.getNotificationType(),
                query.isOwner(), query.getStart(), query.getEnd(), query.getSort(), query.getOrder(),
                serviceContext);

        List<Document> documents = (List<Document>) dossierLogJsonObject.get("data");
        //
        results.setTotal(dossierLogJsonObject.getInt("total"));
        results.getData().addAll(DossierLogUtils.mappingToDossierLogResultsModel(documents));

        return Response.status(200).entity(results).build();

    } catch (Exception e) {
        return processException(e);
    }
}
项目:ch-inofix-contact-manager    文件:EntriesChecker.java   
@Override
public String getRowCheckBox(HttpServletRequest request, boolean checked, boolean disabled, String primaryKey) {

    long entryId = GetterUtil.getLong(primaryKey);

    Contact entry = ContactLocalServiceUtil.fetchContact(entryId);

    boolean showInput = false;

    String name = null;

    if (entry != null) {
        name = Contact.class.getSimpleName();

        try {
            if (ContactPermission.contains(_permissionChecker, entry, ActionKeys.DELETE)) {

                showInput = true;
            }
        } catch (Exception e) {
        }
    }

    if (!showInput) {
        return StringPool.BLANK;
    }

    String checkBoxRowIds = getEntryRowIds();
    String checkBoxAllRowIds = "'#" + getAllRowIds() + "'";

    return getRowCheckBox(request, checked, disabled,
            _liferayPortletResponse.getNamespace() + RowChecker.ROW_IDS + name, primaryKey, checkBoxRowIds,
            checkBoxAllRowIds, StringPool.BLANK);
}
项目:opencps-v2    文件:RegistrationLogManagementImpl.java   
@Override
public Response getRegistrationLogs(HttpServletRequest request, HttpHeaders header, Company company, Locale locale, User user,
        ServiceContext serviceContext, long registrationId, RegistrationLogSearchModel query) {
    BackendAuth auth = new BackendAuthImpl();
    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        RegistrationLogActions action = new RegistrationLogActionsImpl();

        RegistrationLogResultsModel results = new RegistrationLogResultsModel();

        JSONObject registrationLog =  action.getRegistrationLog(groupId, registrationId, query.getStart(), query.getEnd(), query.getSort(), query.getOrder(), serviceContext);

        List<Document> documents = (List<Document>) registrationLog.get("data");
        results.setTotal(registrationLog.getInt("total"));
        results.getData().addAll(RegistrationLogUtils.mappingToRegistrationLoggDataListDocument(documents));

        return Response.status(200).entity(results).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:opencps-v2    文件:RegistrationLogManagementImpl.java   
@Override
public Response getRegistrationLogsbyRegId(HttpServletRequest request, HttpHeaders header, Company company, Locale locale, User user,
        ServiceContext serviceContext, long registrationId) {
    BackendAuth auth = new BackendAuthImpl();
    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        RegistrationLogActions action = new RegistrationLogActionsImpl();

        RegistrationLogResultsModel results = new RegistrationLogResultsModel();

        List<RegistrationLog> lstRegistrationLog = action.getRegistrationLogbyId(groupId, registrationId);

        results.setTotal(lstRegistrationLog.size());
        results.getData().addAll(RegistrationLogUtils.mappingToRegistrationLoggData(lstRegistrationLog));

        return Response.status(200).entity(results).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:opencps-v2    文件:PaymentUrlGenerator.java   
public static void main(String[] args) {
    System.out.println("PaymentUrlGenerator.main()"+GetterUtil.getBoolean("false"));

    String stringToSearch = "http://google.com/dkms?good_code=123123123123&abc=1";

    String pattern1 = "good_code=";
    String pattern2 = "&";

    String regexString = Pattern.quote(pattern1) + "(.*?)" + Pattern.quote(pattern2);

        Pattern p = Pattern.compile(regexString);   // the pattern to search for
        Matcher m = p.matcher(stringToSearch);

        // if we find a match, get the group 
        if (m.find())
        {
          // we're only looking for one group, so get it
          String theGroup = m.group(1);

          System.out.println("PaymentUrlGenerator.main()"+theGroup);
        }

    StringBuffer buf = new StringBuffer();
    buf.append("");

    MessageDigest md5 = null;
    byte[] ba = null;
    // create the md5 hash and UTF-8 encode it
    try {
        md5 = MessageDigest.getInstance("MD5");
        ba = md5.digest(buf.toString().getBytes("UTF-8"));
    } catch (Exception e) {
    } // wont happen
    DateFormat df = new SimpleDateFormat("yy"); // Just the year, with 2 digits
    String formattedDate = df.format(Calendar.getInstance().getTime());
    System.out.println(formattedDate);
    System.out.println("PaymentUrlGenerator.main()"+ HashFunction.hexShort(ba));

}
项目:opencps-v2    文件:ServiceProcessUtils.java   
public static RoleInputModel mappingToServiceRoleInput(ServiceProcessRole processRole) {

        RoleInputModel model = new RoleInputModel();

        model.setRoleId(GetterUtil.getInteger(processRole.getRoleId()));
        model.setRoleName(_getRoleName(processRole.getRoleId()));
        model.setCondition(processRole.getCondition());
        model.setModerator(Boolean.toString(processRole.getModerator()));

        return model;
    }
项目:opencps-v2    文件:ServiceProcessUtils.java   
public static RoleInputModel mappingToServiceRoleInput(ProcessStepRole stepRole) {

        RoleInputModel model = new RoleInputModel();

        model.setRoleId(GetterUtil.getInteger(stepRole.getRoleId()));
        model.setRoleName(_getRoleName(stepRole.getRoleId()));
        model.setCondition(stepRole.getCondition());
        model.setModerator(Boolean.toString(stepRole.getModerator()));

        return model;
    }
项目:opencps-v2    文件:DossierTemplateUtils.java   
public static List<DossierTemplatePartDataModel> mappingToDossierPartList(List<Document> documents) {

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

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

        model.setPartNo(doc.get(DossierPartTerm.PART_NO));
        model.setPartName(doc.get(DossierPartTerm.PART_NAME));
        model.setPartTip(doc.get(DossierPartTerm.PART_TIP));
        model.setPartType(GetterUtil.getInteger(doc.get(DossierPartTerm.PART_TYPE)));
        model.setMultiple(doc.get(DossierPartTerm.MULTIPLE));
        model.setRequired(doc.get(DossierPartTerm.REQUIRED));
        model.setEsign(doc.get(DossierPartTerm.ESIGN));
        model.setFileTemplateNo(doc.get(DossierPartTerm.FILE_TEMPLATE_NO));
        model.setTypeCode(doc.get(DossierPartTerm.DELIVERABLE_TYPE));
        model.setDeliverableAction(GetterUtil.getInteger(doc.get(DossierPartTerm.DELIVERABLE_ACTION)));

        boolean hasForm = false;

        if (Validator.isNotNull(doc.get(DossierPartTerm.FORM_SCRIPT))) {
            hasForm = true;
        }

        model.setHasForm(Boolean.toString(hasForm));

        outputs.add(model);
    }

    return outputs;
}
项目:opencps-v2    文件:PaymentFileManagementImpl.java   
@Override
public Response processingKeyPay(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, String dossierUUid, String paymentFileUUid) {
    // TODO Auto-generated method stub
    URI uri = null;
    try {

        long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
        Dossier dossier = DossierLocalServiceUtil.getByRef(groupId, dossierUUid);

        PaymentFile paymentFile = PaymentFileLocalServiceUtil.getPaymentFileByReferenceUid(dossier.getDossierId(), paymentFileUUid);

        PaymentFileActions actions = new PaymentFileActionsImpl();

        // Change payment Status = 2
        actions.updateFileConfirm(paymentFile.getGroupId(), paymentFile.getDossierId(), paymentFile.getReferenceUid(), StringPool.BLANK, "N\u1ED9p online", JSONFactoryUtil.createJSONObject().toJSONString(), serviceContext);

        JSONObject result = JSONFactoryUtil.createJSONObject();
        result.put("dossierNo", dossier.getDossierNo());
        result.put("serviceName", dossier.getServiceName());
        result.put("govAgencyName", dossier.getGovAgencyName());
        result.put("paymentFee", paymentFile.getPaymentFee());
        result.put("paymentAmount", paymentFile.getPaymentAmount());
        result.put("paymentPortal", "KEYPAY");

        return Response.status(200).entity(result.toJSONString()).build();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return Response.noContent().build();
    }

}
项目:opencps-v2    文件:ServiceInfoUtils.java   
public static List<FileTemplates> mappingToFileTemplates(List<ServiceFileTemplate> serviceFileTemplates) {
    List<FileTemplates> fileTemplates = new ArrayList<FileTemplates>();

    for (ServiceFileTemplate sft : serviceFileTemplates) {
        FileTemplates fileTemplate = new FileTemplates();

        fileTemplate.setTemplateName(sft.getTemplateName());

        if (sft.getFileEntryId() != 0) {

            try {
                FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(sft.getFileEntryId());

                fileTemplate.setFileSize(GetterUtil.getInteger(fileEntry.getSize()));
                fileTemplate.setFileType(fileEntry.getExtension());
                fileTemplate.setFileTemplateNo(sft.getFileTemplateNo());
                fileTemplate.setTemplateName(sft.getTemplateName());

            } catch (Exception e) {
                _log.error("Can't get ServiceFileTemplate");
            }
        }
        fileTemplates.add(fileTemplate);
    }

    return fileTemplates;
}
项目:opencps-v2    文件:RegistrationTemplatesManagementImpl.java   
public Response updateRegistrationTemplateFormScript(HttpServletRequest request, HttpHeaders header,
        Company company, Locale locale, User user, ServiceContext serviceContext, long registrationTemplateId,
        String formScript) {
    // TODO Update FormScript of RegistrationTemplates
    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        RegistrationTemplatesActions action = new RegistrationTemplatesActionsImpl();

        RegistrationTemplates registrationTemplate = action.updateFormScript(groupId, registrationTemplateId,
                formScript, serviceContext);

        RegistrationTemplateDetailModel result = RegistrationTemplatesUtils
                .mappingToRegistrationTemplateModel(registrationTemplate);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:opencps-v2    文件:RegistrationTemplatesManagementImpl.java   
@Override
public Response addRegistrationTemplate(HttpServletRequest request, HttpHeaders header, Company company,
        Locale locale, User user, ServiceContext serviceContext, RegistrationTemplateInputModel input) {
    // TODO Add RegistrationTemplates
    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }
        RegistrationTemplatesActions action = new RegistrationTemplatesActionsImpl();

        RegistrationTemplates registrationTemplate = action.addRegistrationTemplate(groupId,
                input.getGovAgencyCode(), input.getGovAgencyName(), input.getFormNo(), input.getFormName(),
                input.isMultiple(), input.getFormScript(), input.getFormReport(), input.getSampleData(),
                serviceContext);

        RegistrationTemplateDetailModel result = RegistrationTemplatesUtils
                .mappingToRegistrationTemplateModel(registrationTemplate);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        _log.error(e);
        return processException(e);
    }
}
项目:liferay-gsearch    文件:WildcardQueryBuilderImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public WildcardQuery buildQuery(
    JSONObject configurationObject, QueryParams queryParams)
    throws Exception {

    WildcardQuery wildcardQuery = buildClause(configurationObject, queryParams.getKeywords());

    float boost = GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);
    wildcardQuery.setBoost(boost);

    return wildcardQuery;
}
项目:opencps-v2    文件:DeliverablesManagementImpl.java   
@Override
public Response updateFormData(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, Long id, String formdata) {
    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {
        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        DeliverableActions actions = new DeliverableActionsImpl();

        Deliverable deliverable = actions.updateFormData(groupId, id, formdata, serviceContext);

        String formData = deliverable.getFormData();

        JSONObject result = JSONFactoryUtil.createJSONObject(formData);

        return Response.status(200).entity(JSONFactoryUtil.looseSerialize(result)).build();
    } catch (Exception e) {
        ErrorMsg error = new ErrorMsg();

        error.setMessage("not found!");
        error.setCode(404);
        error.setDescription("not found!");

        return Response.status(404).entity(error).build();
    }
}
项目:opencps-v2    文件:NotificationTemplateUtils.java   
public static List<NotificationtemplateModel> mapperNotificationtemplateList(List<Document> listDocument) {

        List<NotificationtemplateModel> results = new ArrayList<>();
        Map<String, String> initTemplates = NotificationMGTConstants.NOTIFICATION_TEMPLATE_INIT;

        try {

            NotificationtemplateModel ett = null;

            for (Document document : listDocument) {
                ett = new NotificationtemplateModel();

                ett.setModifiedDate( Validator.isNotNull(document.get("modified")) &&
                        Validator.isNotNull(document.getDate("modified")) ? APIDateTimeUtils.convertDateToString(
                                document.getDate("modified"), APIDateTimeUtils._TIMESTAMP) : StringPool.BLANK);
                ett.setNotificationType(document.get(NotificationTemplateTerm.NOTIFICATTION_TYPE));

                ett.setTypeName(initTemplates.get(document.get(NotificationTemplateTerm.NOTIFICATTION_TYPE)));

                ett.setEmailSubject(document.get(NotificationTemplateTerm.NOTIFICATION_EMAIL_SUBJECT));
                ett.setEmailBody(document.get(NotificationTemplateTerm.NOTIFICATION_EMAIL_BODY));
                ett.setTextMessage(document.get(NotificationTemplateTerm.NOTIFICATION_TEXT_MESSAGE));
                ett.setSendEmail(Boolean.valueOf(document.get(NotificationTemplateTerm.SEND_EMAIL)));
                ett.setSendSMS(Boolean.valueOf(document.get(NotificationTemplateTerm.NOTIFICATION_SEND_SMS)));
                ett.setExpireDuration(GetterUtil.get(document.get(NotificationTemplateTerm.EXPIRE_DURATION), 0));
                ett.setUserUrlPattern(document.get(NotificationTemplateTerm.USER_URL_PARTTERN));
                ett.setGuestUrlPattern(document.get(NotificationTemplateTerm.GUEST_URL_PARTTERN));
                ett.setInterval(document.get(NotificationTemplateTerm.INTERVAL));
                ett.setGrouping(Boolean.valueOf(document.get(NotificationTemplateTerm.GROUPING)));

                results.add(ett);
            }

        } catch (Exception e) {
            _log.error(e);
        }

        return results;
    }
项目:opencps-v2    文件:DeliverableTypesManagementImpl.java   
@Override
public Response getDeliverableTypes(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext) {
    // TODO Get All Deliverable Type
    BackendAuth auth = new BackendAuthImpl();
    int start = 0, end = 0;
    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        DeliverableTypesResultsModel results = new DeliverableTypesResultsModel();

        DeliverableTypesActions action = new DeliverableTypesActionsImpl();

        JSONObject deliverableTypeJsonObject = action.getDeliverableTypes(groupId, start, end);

        List<DeliverableType> lstDeliverableType = (List<DeliverableType>) deliverableTypeJsonObject
                .get("lstDeliverableType");

        results.setTotal(deliverableTypeJsonObject.getInt("total"));
        results.getData().addAll(DeliverableTypesUtils.mappingToDeliverableTypesResultsModel(lstDeliverableType));

        return Response.status(200).entity(results).build();

    } catch (Exception e) {
        return processException(e);
    }
}
项目:opencps-v2    文件:DeliverableTypesManagementImpl.java   
@Override
public Response updateDeliverableType(HttpServletRequest request, HttpHeaders header, Company company,
        Locale locale, User user, ServiceContext serviceContext, DeliverableTypeInputModel model,
        long deliverableTypeId) {
    // TODO Update Deliverable Type
    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
    String counter = String.valueOf(model.getCounter());

    try {

        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        DeliverableTypesActions action = new DeliverableTypesActionsImpl();

        DeliverableType deliverableType = action.updateDeliverableType(groupId, deliverableTypeId,
                model.getDeliverableName(), model.getDeliverableType(), model.getCodePattern(), counter,
                model.getFormScript(), model.getFormReport(), model.getMappingData(), serviceContext);

        DeliverableTypeDetailModel result = DeliverableTypesUtils.mappingToDeliverableTypesModel(deliverableType);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        return processException(e);
    }
}
项目:opencps-v2    文件:DossierLogManagementImpl.java   
@Override
public Response addDossierLogByDossierId(HttpServletRequest request, HttpHeaders header, Company company,
        Locale locale, User user, ServiceContext serviceContext, long id, String notificationType, String author,
        String payload, String content) {

    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {

        // if (!auth.isAuth(serviceContext)) {
        // throw new UnauthenticationException();
        // }
        DossierLogActions action = new DossierLogActionsImpl();

        DossierLog dossierLog = action.addDossierLog(groupId, id, author, content, notificationType, payload,
                serviceContext);

        DossierLogModel result = DossierLogUtils.mappingToDossierLogModel(dossierLog);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        return processException(e);
    }
}
项目:opencps-v2    文件:DossierActionManagementImpl.java   
@Override
public Response getListContacts(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, long id) {
    // TODO Auto-generated method stub

    DossierActions actions = new DossierActionsImpl();
    List<ListContacts> listContacts = new ArrayList<ListContacts>();

    try {
        long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
        long dossierId = GetterUtil.getLong(id);
        String referenceUid = null;
        if (dossierId == 0) {
            referenceUid = id + "";
        }

        JSONObject jsonData = (JSONObject) actions.getContacts(groupId, dossierId, referenceUid);

        listContacts = DossierActionUtils.mappingToDoListContacts((List<Dossier>) jsonData.get("ListContacts"));

        return Response.status(200).entity(listContacts).build();

    } catch (Exception e) {
        ErrorMsg error = new ErrorMsg();

        if (e instanceof UnauthenticationException) {
            error.setMessage("Non-Authoritative Information.");
            error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
            error.setDescription("Non-Authoritative Information.");

            return Response.status(HttpURLConnection.HTTP_NOT_AUTHORITATIVE).entity(error).build();
        } else {
            if (e instanceof UnauthorizationException) {
                error.setMessage("Unauthorized.");
                error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
                error.setDescription("Unauthorized.");

                return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).entity(error).build();

            } else {

                error.setMessage("Internal Server Error");
                error.setCode(HttpURLConnection.HTTP_FORBIDDEN);
                error.setDescription(e.getMessage());

                return Response.status(HttpURLConnection.HTTP_INTERNAL_ERROR).entity(error).build();

            }
        }
    }
}
项目:ch-inofix-timetracker    文件:TaskRecordIndexer.java   
@Override
public void postProcessContextBooleanFilter(BooleanFilter contextBooleanFilter, SearchContext searchContext)
        throws Exception {

    addStatus(contextBooleanFilter, searchContext);

    // from- and until-date

    Date fromDate = GetterUtil.getDate(searchContext.getAttribute("fromDate"), DateFormat.getDateInstance(), null);
    Date untilDate = GetterUtil.getDate(searchContext.getAttribute("untilDate"), DateFormat.getDateInstance(),
            null);

    long max = Long.MAX_VALUE;
    long min = Long.MIN_VALUE;

    if (fromDate != null) {
        min = fromDate.getTime();
    }

    if (untilDate != null) {
        max = untilDate.getTime();
    }

    contextBooleanFilter.addRangeTerm("fromDate_Number_sortable", min, max);

    // workPackage

    boolean advancedSearch = GetterUtil.getBoolean(searchContext.getAttribute("advancedSearch"), false);
    String workPackage = (String) searchContext.getAttribute("workPackage");

    if (Validator.isNotNull(workPackage) && advancedSearch) {

        BooleanFilter booleanFilter = new BooleanFilter();

        // Use the sortable index field, since the regular field is
        // analyzed, which means, we can't use hyphens in workpackage
        // names.
        PrefixFilter prefixFilter = new PrefixFilter("workPackage_sortable", workPackage);

        booleanFilter.add(prefixFilter);
        contextBooleanFilter.add(booleanFilter, BooleanClauseOccur.MUST);
    }

}
项目:ch-inofix-timetracker    文件:TaskRecordIndexer.java   
@Override
protected void doReindex(String[] ids) throws Exception {

    long companyId = GetterUtil.getLong(ids[0]);
    reindexTaskRecords(companyId);
}
项目:opencps-v2    文件:DeliverablesManagementImpl.java   
@Override
    public Response getFormData(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
            User user, ServiceContext serviceContext, Long id) {

        //TODO
        BackendAuth auth = new BackendAuthImpl();

        try {

            // Check user is login
            if (!auth.isAuth(serviceContext)) {
                throw new UnauthenticationException();
            }

            long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

            //
            LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();

            params.put(Field.GROUP_ID, String.valueOf(groupId));
            params.put(DeliverableTerm.DELIVERABLE_ID, id);

            DeliverableActions actions = new DeliverableActionsImpl();

            // get JSON data deliverable
            JSONObject jsonData = actions.getFormDataById(serviceContext.getCompanyId(), params, null,
                    -1, -1, serviceContext);

            JSONObject results = JSONFactoryUtil.createJSONObject(
                    DeliverableUtils.mappingToDeliverableFormDataModel((List<Document>) jsonData.get("data")));

            return Response.status(200).entity(JSONFactoryUtil.looseSerialize(results)).build();
        } catch (Exception e) {
            ErrorMsg error = new ErrorMsg();

            error.setMessage("not found!");
            error.setCode(404);
            error.setDescription("not found!");

            return Response.status(404).entity(error).build();
        }

//      try {
//          DeliverableActions action = new DeliverableActionsImpl();
//          Deliverable deliverable = action.getListDeliverableDetail(id);
//          return Response.status(200).entity(deliverable.getFormData()).build();
//      } catch (Exception e) {
//          return Response.status(HttpURLConnection.HTTP_INTERNAL_ERROR).entity(e).build();
//      }
    }
项目:opencps-v2    文件:ServerConfigManagementImpl.java   
@Override
public Response updateConfig(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, long id, ServerConfigSingleInputModel input) {

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    BackendAuth auth = new BackendAuthImpl();

    try {
        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        if (!auth.hasResource(serviceContext, ServerConfig.class.getName(), ActionKeys.ADD_ENTRY)) {
            throw new UnauthorizationException();
        }

        ServerConfig oldConfig = ServerConfigLocalServiceUtil.getServerConfig(id);

        ServerConfig config = ServerConfigLocalServiceUtil.updateServerConfig(groupId, id, oldConfig.getServerNo(),
                oldConfig.getServerName(), oldConfig.getProtocol(), input.getValue(), new Date(), serviceContext);

        ServerConfigDetailModel result = ServerConfigUtils.mappingToDetailModel(config);

        return Response.status(200).entity(result).build();

    } catch (Exception e) {
        ErrorMsg error = new ErrorMsg();

        if (e instanceof UnauthenticationException) {
            error.setMessage("Non-Authoritative Information.");
            error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
            error.setDescription("Non-Authoritative Information.");

            return Response.status(HttpURLConnection.HTTP_NOT_AUTHORITATIVE).entity(error).build();
        } else {
            if (e instanceof UnauthorizationException) {
                error.setMessage("Unauthorized.");
                error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
                error.setDescription("Unauthorized.");

                return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).entity(error).build();

            } else {

                error.setMessage("Internal Server Error");
                error.setCode(HttpURLConnection.HTTP_FORBIDDEN);
                error.setDescription(e.getMessage());

                return Response.status(HttpURLConnection.HTTP_INTERNAL_ERROR).entity(error).build();

            }
        }
    }
}
项目:opencps-v2    文件:PaymentFileLocalServiceImpl.java   
/**
 * Create a payment File
 * 
 * @param
 * @return PaymentFile
 */
@Indexable(type = IndexableType.REINDEX)
public PaymentFile createPaymentFiles(long userId, long groupId, long dossierId, String referenceUid,
        String govAgencyCode, String govAgencyName, String applicantName, String applicantIdNo, String paymentFee,
        long paymentAmount, String paymentNote, String epaymentProfile, String bankInfo,
        ServiceContext serviceContext) throws PortalException {

    // validate(groupId, serviceConfigId, serviceInfoId, govAgencyCode,
    // serviceLevel, serviceUrl, objName);

    Date now = new Date();

    User auditUser = userPersistence.fetchByPrimaryKey(userId);

    long paymentFileId = counterLocalService.increment(PaymentFile.class.getName());

    PaymentFile paymentFile = paymentFilePersistence.create(paymentFileId);

    paymentFile.setGroupId(groupId);
    paymentFile.setCompanyId(auditUser.getCompanyId());
    paymentFile.setUserId(auditUser.getUserId());
    paymentFile.setUserName(auditUser.getFullName());
    paymentFile.setCreateDate(now);
    paymentFile.setModifiedDate(now);

    paymentFile.setDossierId(dossierId);
    paymentFile.setReferenceUid(referenceUid);
    paymentFile.setGovAgencyCode(govAgencyCode);
    paymentFile.setGovAgencyName(govAgencyName);
    paymentFile.setPaymentFee(paymentFee);
    paymentFile.setPaymentAmount(GetterUtil.getLong(paymentAmount));
    paymentFile.setPaymentNote(paymentNote);
    paymentFile.setEpaymentProfile(epaymentProfile);
    paymentFile.setBankInfo(bankInfo);

    // WTF?...
    /*
     * try { Dossier dossier =
     * DossierLocalServiceUtil.getDossier(dossierId);
     * dossier.setApplicantName(applicantName);
     * dossier.setApplicantIdNo(applicantIdNo);
     * 
     * dossierPersistence.update(dossier); } catch (Exception e) {
     * e.printStackTrace(); }
     */

    paymentFilePersistence.update(paymentFile);

    return paymentFile;
}
项目:opencps-v2    文件:DossierStatisticIndexer.java   
@Override
protected void doReindex(String[] ids) throws Exception {
    long companyId = GetterUtil.getLong(ids[0]);
    reindex(companyId);

}