Search in sources :

Example 1 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class ConcurManageRefreshTokenAction method updateFormValues.

protected void updateFormValues(ConcurManageRefreshTokenForm concurTokenForm, boolean displayUpdateRefreshTokenMessage, boolean displayUpdateRequestTokenMessage) {
    ConfigurationService configService = getConfigurationService();
    concurTokenForm.setNonProdWarning(configService.getPropertyValueAsString(ConcurKeyConstants.MESSAGE_CONCUR_REFRESH_TOKEN_NONPROD_WARNING));
    concurTokenForm.setDisplayNonProdWarning(!isProduction());
    String refreshTokenUpdateDate = MessageFormat.format(configService.getPropertyValueAsString(ConcurKeyConstants.MESSAGE_CONCUR_TOKEN_DATE), "refresh", getTokenUpdateTimestamp(ConcurConstants.ConcurOAuth2.WebServiceCredentialKeys.REFRESH_TOKEN).toString());
    String updateRefreshSuccessMessage = MessageFormat.format(configService.getPropertyValueAsString(ConcurKeyConstants.MESSAGE_CONCUR_TOKEN_UPDATE_SUCCESS), "refresh");
    concurTokenForm.setRefreshTokenUpdateDate(refreshTokenUpdateDate);
    concurTokenForm.setUpdateRefreshTokenMessage(updateRefreshSuccessMessage);
    concurTokenForm.setDisplayUpdateRefreshTokenMessage(displayUpdateRefreshTokenMessage);
    String requestTokenUpdateDate = MessageFormat.format(configService.getPropertyValueAsString(ConcurKeyConstants.MESSAGE_CONCUR_TOKEN_DATE), "request", getTokenUpdateTimestamp(ConcurConstants.ConcurOAuth2.WebServiceCredentialKeys.REQUEST_TOKEN).toString());
    String updateRequestSuccessMessage = MessageFormat.format(configService.getPropertyValueAsString(ConcurKeyConstants.MESSAGE_CONCUR_TOKEN_UPDATE_SUCCESS), "request");
    concurTokenForm.setRequestTokenUpdateDate(requestTokenUpdateDate);
    concurTokenForm.setUpdateRequestTokenMessage(updateRequestSuccessMessage);
    concurTokenForm.setDisplayUpdateRequestTokenMessage(displayUpdateRequestTokenMessage);
    concurTokenForm.setUpdateRequestTokenInstructions(getConcurBatchUtilityService().getConcurParameterValue(ConcurParameterConstants.CONCUR_OAUTH2_REPLACE_REQUEST_TOKEN_INSTRUCTIONS));
    concurTokenForm.setNewRequestToken(StringUtils.EMPTY);
}
Also used : ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService)

Example 2 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentAction method promptForFinalBillConfirmation.

protected ActionForward promptForFinalBillConfirmation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String caller, String warningMessage, ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) throws Exception {
    ActionForward forward = null;
    Object question = request.getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
    if (question == null) {
        return performQuestionWithoutInput(mapping, form, request, response, CuArConstants.CINV_FINAL_BILL_INDICATOR_CONFIRMATION_QUESTION, warningMessage, KFSConstants.CONFIRMATION_QUESTION, caller, StringUtils.EMPTY);
    }
    Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
    if (CuArConstants.CINV_FINAL_BILL_INDICATOR_CONFIRMATION_QUESTION.equals(question)) {
        if (ConfirmationQuestion.NO.equals(buttonClicked)) {
            forward = mapping.findForward(KFSConstants.MAPPING_BASIC);
        } else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
            try {
                Pair<Date, Date> billingPeriod = parseDateRange(contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getBillingPeriod());
                Date billingPeriodEndDate = billingPeriod.getRight();
                DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
                if (dateTimeService.dateDiff(billingPeriodEndDate, contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getLastBilledDate(), false) != 0) {
                    contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().setLastBilledDate(billingPeriodEndDate);
                }
            } catch (Exception ex) {
                ConfigurationService configurationService = SpringContext.getBean(ConfigurationService.class);
                String message = configurationService.getPropertyValueAsString(CUKFSKeyConstants.ERROR_CINV_SETTING_LAST_BILLED_DATE);
                GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_CUSTOM, message);
                return mapping.findForward(KFSConstants.MAPPING_BASIC);
            }
        }
    }
    return forward;
}
Also used : ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService) ActionForward(org.apache.struts.action.ActionForward) Date(java.sql.Date) ParseException(java.text.ParseException) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class CuAutoDisapproveDocumentsServiceImpl method buildSuccessMessage.

private String buildSuccessMessage(Document document) throws Exception {
    StringBuilder headerBuilder = new StringBuilder();
    headerBuilder.append(document.getDocumentNumber());
    headerBuilder.append(TAB);
    headerBuilder.append(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
    headerBuilder.append(TAB);
    headerBuilder.append(document.getDocumentHeader().getDocumentDescription());
    headerBuilder.append(TAB);
    headerBuilder.append(getPersonService().getPerson(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId()).getPrincipalName());
    headerBuilder.append(TAB);
    headerBuilder.append(getPersonService().getPerson(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId()).getName());
    headerBuilder.append(TAB);
    headerBuilder.append(document.getDocumentHeader().getWorkflowDocument().getDateCreated());
    headerBuilder.append(TAB);
    ConfigurationService k = KRADServiceLocator.getKualiConfigurationService();
    StringBuilder routeBuilder = new StringBuilder();
    String url = k.getPropertyValueAsString("workflow.url");
    routeBuilder.append(url);
    routeBuilder.append("/RouteLog.do?routeHeaderId=");
    routeBuilder.append(document.getDocumentNumber());
    routeBuilder.append(TAB);
    headerBuilder.append(routeBuilder);
    List<ActionTaken> actions;
    // try {
    // actions = KEWServiceLocator.getActionTakenService().findByDocumentId(document.getDocumentHeader().getWorkflowDocument().getDocumentId());
    actions = KEWServiceLocator.getActionTakenService().findByDocumentIdIgnoreCurrentInd(document.getDocumentNumber());
    ActionTaken max = null;
    for (ActionTaken at : actions) {
        if (ObjectUtils.isNull(max)) {
            max = at;
        } else if (at.getActionDate().compareTo(max.getActionDate()) > 0) {
            max = at;
        }
    }
    headerBuilder.append(getPersonService().getPerson(max.getPrincipalId()).getPrincipalName());
    headerBuilder.append(TAB);
    headerBuilder.append(getPersonService().getPerson(max.getPrincipalId()).getName());
    headerBuilder.append(TAB);
    headerBuilder.append(max.getActionDate());
    headerBuilder.append(TAB);
    headerBuilder.append(max.getActionTakenLabel());
    headerBuilder.append(TAB);
    // } catch (WorkflowException e) {
    // e.printStackTrace();
    // }
    String headerString = headerBuilder.toString();
    StringBuilder builder = new StringBuilder();
    if (document instanceof AccountingDocumentBase) {
        for (Object o : ((AccountingDocumentBase) document).getSourceAccountingLines()) {
            SourceAccountingLine sal = (SourceAccountingLine) o;
            builder.append(headerString);
            builder.append(sal.getChartOfAccountsCode());
            builder.append(TAB);
            builder.append(sal.getAccountNumber());
            builder.append(TAB);
            builder.append(sal.getAmount());
            builder.append(TAB);
            builder.append(sal.getAccount().getOrganizationCode());
            builder.append(TAB);
            builder.append(KFSConstants.NEWLINE);
        }
        for (Object o : ((AccountingDocumentBase) document).getTargetAccountingLines()) {
            TargetAccountingLine tal = (TargetAccountingLine) o;
            builder.append(headerString);
            builder.append(tal.getChartOfAccountsCode());
            builder.append(TAB);
            builder.append(tal.getAccountNumber());
            builder.append(TAB);
            builder.append(tal.getAmount());
            builder.append(TAB);
            builder.append(tal.getAccount().getOrganizationCode());
            builder.append(TAB);
            builder.append(KFSConstants.NEWLINE);
        }
    }
    return builder.toString();
}
Also used : TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) AccountingDocumentBase(org.kuali.kfs.sys.document.AccountingDocumentBase) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Example 4 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class PreferencesServiceImpl method getPreferences.

public Preferences getPreferences(String principalId) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("start preferences fetch user " + principalId);
    }
    Collection<UserOptions> options = getUserOptionService().findByWorkflowUser(principalId);
    Map<String, UserOptions> optionMap = new HashMap<>();
    Map<String, String> optionValueMap = new HashMap<>();
    Map<String, String> documentTypeNotificationPreferences = new HashMap<>();
    for (UserOptions option : options) {
        if (option.getOptionId().endsWith(KewApiConstants.DOCUMENT_TYPE_NOTIFICATION_PREFERENCE_SUFFIX)) {
            String preferenceName = option.getOptionId();
            preferenceName = StringUtils.substringBeforeLast(preferenceName, KewApiConstants.DOCUMENT_TYPE_NOTIFICATION_PREFERENCE_SUFFIX);
            documentTypeNotificationPreferences.put(preferenceName, option.getOptionVal());
        } else {
            optionMap.put(option.getOptionId(), option);
        }
    }
    ConfigurationService kcs = CoreApiServiceLocator.getKualiConfigurationService();
    boolean isSaveRequired = false;
    for (Map.Entry<String, String> entry : USER_OPTION_KEY_DEFAULT_MAP.entrySet()) {
        String optionKey = entry.getKey();
        String defaultValue = kcs.getPropertyValueAsString(entry.getValue());
        if (LOG.isDebugEnabled()) {
            LOG.debug("start fetch option " + optionKey + " user " + principalId);
        }
        UserOptions option = optionMap.get(optionKey);
        if (option == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("User option '" + optionKey + "' on user " + principalId + " has no stored value.  Preferences will require save.");
            }
            option = new UserOptions();
            option.setWorkflowId(principalId);
            option.setOptionId(optionKey);
            option.setOptionVal(defaultValue);
            // just in case referenced a second time
            optionMap.put(optionKey, option);
            if (!isSaveRequired) {
                if (!optionKey.equals(Preferences.KEYS.USE_OUT_BOX) || ConfigContext.getCurrentContextConfig().getOutBoxOn()) {
                    isSaveRequired = true;
                }
            }
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("End fetch option " + optionKey + " user " + principalId);
        }
        optionValueMap.put(optionKey, option.getOptionVal());
    }
    return Preferences.Builder.create(optionValueMap, documentTypeNotificationPreferences, isSaveRequired).build();
}
Also used : UserOptions(org.kuali.kfs.kew.useroptions.UserOptions) HashMap(java.util.HashMap) ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ConfigurationService

use of org.kuali.kfs.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.

the class CreateAccountingDocumentServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    ConfigurationService configurationService = buildMockConfigurationService();
    DateTimeService dateTimeService = buildMockDateTimeService();
    ParameterService parameterService = buildParameterService();
    CuDisbursementVoucherDefaultDueDateService cuDisbursementVoucherDefaultDueDateService = buildCuDisbursementVoucherDefaultDueDateService();
    createAccountingDocumentService = new TestCreateAccountingDocumentServiceImpl(buildMockPersonService(), buildAccountingXmlDocumentDownloadAttachmentService(), configurationService, buildMockFiscalYearFunctionControlService(), buildMockDisbursementVoucherTravelService(), buildMockUniversityDateService(), buildAccountingPeriodService(), dateTimeService, cuDisbursementVoucherDefaultDueDateService, buildCuDisbursementVoucherPayeeService(), buildMockVendorService());
    createAccountingDocumentService.initializeDocumentGeneratorsFromMappings(AccountingDocumentMapping.DI_DOCUMENT, AccountingDocumentMapping.IB_DOCUMENT, AccountingDocumentMapping.TF_DOCUMENT, AccountingDocumentMapping.BA_DOCUMENT, AccountingDocumentMapping.SB_DOCUMENT, AccountingDocumentMapping.YEDI_DOCUMENT, AccountingDocumentMapping.DV_DOCUMENT, AccountingDocumentMapping.YEBA_DOCUMENT, AccountingDocumentMapping.YETF_DOCUMENT, AccountingDocumentMapping.AV_DOCUMENT);
    createAccountingDocumentService.setAccountingDocumentBatchInputFileType(buildAccountingXmlDocumentInputFileType(dateTimeService));
    createAccountingDocumentService.setBatchInputFileService(new BatchInputFileServiceImpl());
    createAccountingDocumentService.setFileStorageService(buildFileStorageService());
    createAccountingDocumentService.setConfigurationService(configurationService);
    createAccountingDocumentService.setDocumentService(buildMockDocumentService());
    createAccountingDocumentService.setCreateAccountingDocumentReportService(new TestCreateAccountingDocumentReportService());
    createAccountingDocumentService.setParameterService(parameterService);
    createAccountingDocumentService.setCreateAccountingDocumentValidationService(buildCreateAccountingDocumentValidationService(configurationService));
    routedAccountingDocuments = new ArrayList<>();
    creationOrderedBaseFileNames = new ArrayList<>();
    createTargetTestDirectory();
    dateFormat = new SimpleDateFormat(CUKFSConstants.DATE_FORMAT_yyyyMMdd, Locale.US);
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) BatchInputFileServiceImpl(org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl) CuDisbursementVoucherDefaultDueDateService(edu.cornell.kfs.fp.document.service.CuDisbursementVoucherDefaultDueDateService) ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService) SimpleDateFormat(java.text.SimpleDateFormat) Before(org.junit.Before)

Aggregations

ConfigurationService (org.kuali.kfs.core.api.config.property.ConfigurationService)13 DateTimeService (org.kuali.kfs.core.api.datetime.DateTimeService)3 Date (java.sql.Date)2 ParseException (java.text.ParseException)2 CuDisbursementVoucherDefaultDueDateService (edu.cornell.kfs.fp.document.service.CuDisbursementVoucherDefaultDueDateService)1 CreateDoneBatchFile (edu.cornell.kfs.sys.batch.CreateDoneBatchFile)1 File (java.io.File)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Pair (org.apache.commons.lang3.tuple.Pair)1 ActionForward (org.apache.struts.action.ActionForward)1 Before (org.junit.Before)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 ActionTaken (org.kuali.kfs.kew.actiontaken.ActionTaken)1 UserOptions (org.kuali.kfs.kew.useroptions.UserOptions)1 BatchFile (org.kuali.kfs.sys.batch.BatchFile)1 BatchInputFileServiceImpl (org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl)1