コード例 #1
0
  /**
   * Performs additional indexing based on the view type associated with the view instance. The
   * {@code ViewTypeService} associated with the view type name on the instance is invoked to
   * retrieve the parameter key/value pairs from the configured property values, which are then used
   * to build up an index used to key the entry
   *
   * @param propertyValues - property values configured on the view bean definition
   * @param id - id (or bean name if id was not set) for the view
   */
  protected void indexViewForType(PropertyValues propertyValues, String id) {
    String viewTypeName = ViewModelUtils.getStringValFromPVs(propertyValues, "viewTypeName");
    if (StringUtils.isBlank(viewTypeName)) {
      return;
    }

    UifConstants.ViewType viewType = ViewType.valueOf(viewTypeName);

    ViewTypeService typeService =
        KRADServiceLocatorWeb.getViewService().getViewTypeService(viewType);
    if (typeService == null) {
      // don't do any further indexing
      return;
    }

    // invoke type service to retrieve it parameter name/value pairs
    Map<String, String> typeParameters =
        typeService.getParametersFromViewConfiguration(propertyValues);

    // build the index string from the parameters
    String index = buildTypeIndex(typeParameters);

    // get the index for the type and add the view entry
    ViewTypeDictionaryIndex typeIndex = getTypeIndex(viewType);

    typeIndex.put(index, id);
  }
コード例 #2
0
  /**
   * The following actions are performed:
   *
   * <ul>
   *   <li>Add all option if enabled and control is multi-value
   * </ul>
   *
   * {@inheritDoc}
   */
  @Override
  public void performFinalize(Object model, LifecycleElement parent) {
    super.performFinalize(model, parent);

    // if enabled add option to select all values
    if (addControlSelectAllOption
        && (getControl() != null)
        && getControl() instanceof MultiValueControl) {
      String allOptionText =
          KRADServiceLocatorWeb.getMessageService()
              .getMessageText(UifConstants.MessageKeys.OPTION_ALL);

      MultiValueControl multiValueControl = (MultiValueControl) getControl();
      if (multiValueControl.getOptions() != null) {
        multiValueControl.getOptions().add(0, new ConcreteKeyValue("", allOptionText));
      }

      if (multiValueControl.getRichOptions() != null) {
        Message message = ComponentFactory.getMessage();
        message.setMessageText(allOptionText);
        message.setRenderWrapperTag(false);

        multiValueControl.getRichOptions().add(0, new KeyMessage("", allOptionText, message));
      }
    }
  }
  public ActionForward addResponsibility(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
    KimDocumentRoleResponsibility newResponsibility = roleDocumentForm.getResponsibility();
    if (newResponsibility != null
        && StringUtils.isNotBlank(newResponsibility.getResponsibilityId())) {
      ResponsibilityBo responsibilityImpl =
          KradDataServiceLocator.getDataObjectService()
              .find(ResponsibilityBo.class, newResponsibility.getResponsibilityId());
      newResponsibility.setKimResponsibility(responsibilityImpl);
    }

    if (KRADServiceLocatorWeb.getKualiRuleService()
        .applyRules(
            new AddResponsibilityEvent(
                "", roleDocumentForm.getRoleDocument(), newResponsibility))) {
      if (newResponsibility != null) {
        newResponsibility.setDocumentNumber(roleDocumentForm.getDocument().getDocumentNumber());
      }
      roleDocumentForm.getRoleDocument().addResponsibility(newResponsibility);
      roleDocumentForm.setResponsibility(new KimDocumentRoleResponsibility());
      roleDocumentForm.getRoleDocument().updateMembers(newResponsibility);
    }
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
  }
コード例 #4
0
  protected boolean isOkHavingDifferentObjectSubTypes() {
    String parameterDetail =
        "(module:"
            + KRADServiceLocatorWeb.getKualiModuleService().getNamespaceCode(Asset.class)
            + "/component:"
            + Asset.class.getSimpleName()
            + ")";
    ConfigurationService kualiConfiguration = SpringContext.getBean(ConfigurationService.class);

    String continueQuestion =
        kualiConfiguration.getPropertyValueAsString(KFSKeyConstants.CONTINUE_QUESTION);
    String warningMessage =
        kualiConfiguration.getPropertyValueAsString(
                KFSKeyConstants.WARNING_NOT_SAME_OBJECT_SUB_TYPES)
            + " "
            + KFSParameterKeyConstants.CamParameterConstants.OBJECT_SUB_TYPE_GROUPS
            + " "
            + parameterDetail
            + ". "
            + continueQuestion;
    return super.askOrAnalyzeYesNoQuestion(
        KFSConstants.FinancialDocumentTypeCodes
            .ASSET_DIFFERENT_OBJECT_SUB_TYPE_CONFIRMATION_QUESTION,
        warningMessage);
  }
コード例 #5
0
  /**
   * Handles exporting the BusinessObject for this Inquiry to XML if it has a custom XML exporter
   * available.
   */
  @RequestMapping(params = "methodToCall=export")
  public ModelAndView export(
      @ModelAttribute("KualiForm") UifFormBase form,
      BindingResult result,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    InquiryForm inquiryForm = (InquiryForm) form;

    Object dataObject = inquiryForm.getDataObject();
    if (dataObject != null) {
      DataObjectEntry dataObjectEntry =
          KRADServiceLocatorWeb.getDataDictionaryService()
              .getDataDictionary()
              .getDataObjectEntry(inquiryForm.getDataObjectClassName());

      Class<? extends Exporter> exporterClass = dataObjectEntry.getExporterClass();
      if (exporterClass != null) {
        Exporter exporter = exporterClass.newInstance();

        response.setContentType(KRADConstants.XML_MIME_TYPE);
        response.setHeader("Content-disposition", "attachment; filename=export.xml");
        exporter.export(
            dataObjectEntry.getDataObjectClass(),
            Collections.singletonList(dataObject),
            KRADConstants.XML_FORMAT,
            response.getOutputStream());
      }
    }

    return null;
  }
コード例 #6
0
  private SubAwardDocument getSubAwardDocument() throws WorkflowException {
    SubAwardDocument document =
        (SubAwardDocument)
            KRADServiceLocatorWeb.getDocumentService().getNewDocument(SubAwardDocument.class);
    document.getDocumentHeader().setDocumentDescription("SubcontractDocumentTest test doc");
    SubAward subAward = new SubAward();
    subAward.setOrganizationId("000001");
    subAward.setSubAwardTypeCode(229);
    subAward.setSubAwardCode("7687");
    subAward.setStatusCode(123);
    subAward.setPurchaseOrderNum("111");
    subAward.setRequisitionerId("1");

    document.setSubAward(subAward);
    KRADServiceLocatorWeb.getDocumentService().saveDocument(document);
    return document;
  }
コード例 #7
0
 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=validateView")
 public ModelAndView validateView(
     @ModelAttribute("KualiForm") UifFormBase uiTestForm,
     BindingResult result,
     HttpServletRequest request,
     HttpServletResponse response) {
   KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm);
   return getUIFModelAndView(uiTestForm);
 }
コード例 #8
0
 protected void loadDocumentInForm(
     HttpServletRequest request, InstitutionalProposalForm institutionalProposalForm)
     throws WorkflowException {
   String docIdRequestParameter = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
   InstitutionalProposalDocument retrievedDocument =
       (InstitutionalProposalDocument)
           KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(docIdRequestParameter);
   institutionalProposalForm.setDocument(retrievedDocument);
   request.setAttribute(KRADConstants.PARAMETER_DOC_ID, docIdRequestParameter);
 }
コード例 #9
0
  /**
   * Parses and returns the lookup result set limit, checking first for the limit for the specific
   * view, then the class being looked up, and then the global application limit if there isn't a
   * limit specific to this data object class.
   *
   * @param dataObjectClass - class to get limit for
   * @param lookupForm - LookupForm to use. May be null if the form is unknown. If lookupForm is
   *     null, only the dataObjectClass will be used to find the search results set limit
   * @return result set limit
   */
  public static Integer getSearchResultsLimit(Class dataObjectClass, LookupForm lookupForm) {
    Integer limit =
        KRADServiceLocatorWeb.getViewDictionaryService()
            .getResultSetLimitForLookup(dataObjectClass, lookupForm);
    if (limit == null) {
      limit = getApplicationSearchResultsLimit();
    }

    return limit;
  }
コード例 #10
0
 private void changeTheme(UifFormBase form) {
   String theme = ((KradSampleAppForm) form).getThemeName();
   if (theme != null) {
     ViewTheme newTheme =
         (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryBean(theme));
     if (newTheme != null) {
       form.getView().setTheme(newTheme);
     }
   }
 }
  public ActionForward addDelegationMember(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
    RoleDocumentDelegationMember newDelegationMember = roleDocumentForm.getDelegationMember();

    // See if possible to add with just Group Details filled in (not returned from lookup)
    if (StringUtils.isEmpty(newDelegationMember.getMemberId())
        && StringUtils.isNotEmpty(newDelegationMember.getMemberName())
        && StringUtils.isNotEmpty(newDelegationMember.getMemberNamespaceCode())
        && StringUtils.equals(
            newDelegationMember.getMemberTypeCode(),
            KimConstants.KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode())) {
      Group tempGroup =
          KimApiServiceLocator.getGroupService()
              .getGroupByNamespaceCodeAndName(
                  newDelegationMember.getMemberNamespaceCode(),
                  newDelegationMember.getMemberName());
      if (tempGroup != null) {
        newDelegationMember.setMemberId(tempGroup.getId());
      }
    }

    // See if possible to grab details for Principal
    if (StringUtils.isEmpty(newDelegationMember.getMemberId())
        && StringUtils.isNotEmpty(newDelegationMember.getMemberName())
        && StringUtils.equals(
            newDelegationMember.getMemberTypeCode(),
            KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode())) {
      Principal principal =
          KimApiServiceLocator.getIdentityService()
              .getPrincipalByPrincipalName(newDelegationMember.getMemberName());
      if (principal != null) {
        newDelegationMember.setMemberId(principal.getPrincipalId());
      }
    }

    if (checkDelegationMember(newDelegationMember)
        && KRADServiceLocatorWeb.getKualiRuleService()
            .applyRules(
                new AddDelegationMemberEvent(
                    "", roleDocumentForm.getRoleDocument(), newDelegationMember))) {
      newDelegationMember.setDocumentNumber(roleDocumentForm.getDocument().getDocumentNumber());
      if (StringUtils.isEmpty(newDelegationMember.getDelegationTypeCode())) {
        newDelegationMember.setDelegationTypeCode(DelegationType.SECONDARY.getCode());
      }
      roleDocumentForm.getRoleDocument().addDelegationMember(newDelegationMember);
      roleDocumentForm.setDelegationMember(
          roleDocumentForm.getRoleDocument().getBlankDelegationMember());
    }
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
  }
コード例 #12
0
  /**
   * Creates a list of search fields, one for each primary key of the maintained business object
   *
   * @param businessObjectClass the class of the maintained business object
   * @return a List of KEW search fields
   */
  protected List<Row> createFieldRowsForBusinessObject(
      Class<? extends BusinessObject> businessObjectClass) {
    List<Row> searchFields = new ArrayList<Row>();

    final List primaryKeyNamesAsObjects =
        KRADServiceLocatorWeb.getLegacyDataAdapter().listPrimaryKeyFieldNames(businessObjectClass);
    final BusinessObjectEntry boEntry =
        KRADServiceLocatorWeb.getDataDictionaryService()
            .getDataDictionary()
            .getBusinessObjectEntry(businessObjectClass.getName());
    final WorkflowAttributePropertyResolutionService propertyResolutionService =
        KNSServiceLocator.getWorkflowAttributePropertyResolutionService();
    for (Object primaryKeyNameAsObject : primaryKeyNamesAsObjects) {

      String attributeName = (String) primaryKeyNameAsObject;
      BusinessObject businessObject = null;
      try {
        businessObject = businessObjectClass.newInstance();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }

      Field searchField = FieldUtils.getPropertyField(businessObjectClass, attributeName, false);
      String dataType =
          propertyResolutionService.determineFieldDataType(businessObjectClass, attributeName);
      searchField.setFieldDataType(dataType);
      List<Field> fieldList = new ArrayList<Field>();

      List displayedFieldNames = new ArrayList();
      displayedFieldNames.add(attributeName);
      LookupUtils.setFieldQuickfinder(
          businessObject, attributeName, searchField, displayedFieldNames);

      fieldList.add(searchField);
      searchFields.add(new Row(fieldList));
    }

    return searchFields;
  }
コード例 #13
0
  /**
   * Create a proposal development document. For testing purposes, we only need its proposal number
   * to be set.
   */
  private ProposalDevelopmentDocument createProposal(
      String documentDescription, String leadUnitNumber) throws Exception {
    ProposalDevelopmentDocument document =
        (ProposalDevelopmentDocument)
            KRADServiceLocatorWeb.getDocumentService()
                .getNewDocument("ProposalDevelopmentDocument");

    Date requestedStartDateInitial = new Date(System.currentTimeMillis());
    Date requestedEndDateInitial = new Date(System.currentTimeMillis());

    document.getDocumentHeader().setDocumentDescription(documentDescription);
    document.getDevelopmentProposal().setSponsorCode("000162");
    document.getDevelopmentProposal().setTitle("project title");
    document.getDevelopmentProposal().setRequestedStartDateInitial(requestedStartDateInitial);
    document.getDevelopmentProposal().setRequestedEndDateInitial(requestedEndDateInitial);
    document.getDevelopmentProposal().setActivityTypeCode("1");
    document.getDevelopmentProposal().setProposalTypeCode("1");
    document.getDevelopmentProposal().setOwnedByUnitNumber(leadUnitNumber);
    document.getDevelopmentProposal().setPrimeSponsorCode("000120");

    proposalDevelopmentService.initializeUnitOrganizationLocation(document);
    proposalDevelopmentService.initializeProposalSiteNumbers(document);

    document =
        (ProposalDevelopmentDocument)
            KRADServiceLocatorWeb.getDocumentService().saveDocument(document);
    initializeProposalUsers(document);

    document =
        (ProposalDevelopmentDocument)
            KRADServiceLocatorWeb.getDocumentService().saveDocument(document);
    ProposalDevelopmentDocument savedDocument =
        (ProposalDevelopmentDocument)
            KRADServiceLocatorWeb.getDocumentService()
                .getByDocumentHeaderId(document.getDocumentNumber());
    assertNotNull(savedDocument);

    return savedDocument;
  }
コード例 #14
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 protected void transformWildCardableFields(
     Class<? extends HrBusinessObjectContract> hrBOClass, Map formProps) {
   Iterator propsIter = formProps.keySet().iterator();
   while (propsIter.hasNext()) {
     String propertyName = (String) propsIter.next();
     String propertyValue = (String) formProps.get(propertyName);
     if (StringUtils.isNotBlank(propertyValue)) {
       // transform this value into an "OR" with the wildcard symbols
       boolean canContainWildcard = false;
       if (KRADServiceLocatorWeb.getDataDictionaryService()
           .isAttributeDefined(hrBOClass, propertyName)) {
         AttributeDefinition attributeDefinition =
             KRADServiceLocatorWeb.getDataDictionaryService()
                 .getAttributeDefinition(hrBOClass.getName(), propertyName);
         // check if this property is wildcarded
         if (attributeDefinition instanceof WildcardableAttributeDefinition) {
           canContainWildcard =
               ((WildcardableAttributeDefinition) attributeDefinition).getContainsWildcardData();
         }
         if (canContainWildcard) {
           // get the wildcard symbols and attach them with an "OR" seperator i.e. "|"
           List<String> wildcardStrings =
               ((WildcardableAttributeDefinition) attributeDefinition).getAllowedWildcardStrings();
           if (wildcardStrings != null) {
             for (String wildcardString : wildcardStrings) {
               if (StringUtils.equals("*", wildcardString)
                   || StringUtils.equals("%", wildcardString)) {
                 wildcardString = "\\" + wildcardString;
               }
               propertyValue = propertyValue + SearchOperator.OR.op() + wildcardString;
             }
             formProps.put(propertyName, propertyValue);
           }
         }
       }
     }
   }
 }
コード例 #15
0
  /**
   * Produces legacy KNS rows to use for search attributes. This method was left intact to help ease
   * conversion until KNS is replaced with KRAD.
   */
  protected List<Row> getSearchingRows(String documentTypeName) {

    List<Row> docSearchRows = new ArrayList<Row>();

    Class boClass = DocumentHeader.class;

    Field descriptionField = FieldUtils.getPropertyField(boClass, "documentDescription", true);
    descriptionField.setFieldDataType(
        KewApiConstants.SearchableAttributeConstants.DATA_TYPE_STRING);

    Field orgDocNumberField =
        FieldUtils.getPropertyField(boClass, "organizationDocumentNumber", true);
    orgDocNumberField.setFieldDataType(
        KewApiConstants.SearchableAttributeConstants.DATA_TYPE_STRING);

    List<Field> fieldList = new ArrayList<Field>();
    fieldList.add(descriptionField);
    docSearchRows.add(new Row(fieldList));

    fieldList = new ArrayList<Field>();
    fieldList.add(orgDocNumberField);
    docSearchRows.add(new Row(fieldList));

    DocumentEntry entry =
        KRADServiceLocatorWeb.getDataDictionaryService()
            .getDataDictionary()
            .getDocumentEntry(documentTypeName);
    if (entry == null) return docSearchRows;
    if (entry instanceof MaintenanceDocumentEntry) {
      Class<? extends BusinessObject> businessObjectClass =
          getBusinessObjectClass(documentTypeName);
      Class<? extends Maintainable> maintainableClass = getMaintainableClass(documentTypeName);

      KualiGlobalMaintainableImpl globalMaintainable = null;
      try {
        globalMaintainable = (KualiGlobalMaintainableImpl) maintainableClass.newInstance();
        businessObjectClass = globalMaintainable.getPrimaryEditedBusinessObjectClass();
      } catch (Exception ie) {
        // was not a globalMaintainable.
      }

      if (businessObjectClass != null)
        docSearchRows.addAll(createFieldRowsForBusinessObject(businessObjectClass));
    }

    WorkflowAttributes workflowAttributes = entry.getWorkflowAttributes();
    if (workflowAttributes != null)
      docSearchRows.addAll(createFieldRowsForWorkflowAttributes(workflowAttributes));

    return docSearchRows;
  }
コード例 #16
0
  /**
   * gets the relationship that the attribute represents on the class
   *
   * @param c - the class to which the attribute belongs
   * @param attributeName - property name for the attribute
   * @return a relationship definition for the attribute
   */
  @Override
  public RelationshipDefinition getDictionaryRelationship(Class<?> c, String attributeName) {
    DataDictionaryEntry entryBase =
        KRADServiceLocatorWeb.getDataDictionaryService()
            .getDataDictionary()
            .getDictionaryObjectEntry(c.getName());
    if (entryBase == null) {
      return null;
    }

    RelationshipDefinition relationship = null;

    List<RelationshipDefinition> ddRelationships = entryBase.getRelationships();

    int minKeys = Integer.MAX_VALUE;
    for (RelationshipDefinition def : ddRelationships) {
      // favor key sizes of 1 first
      if (def.getPrimitiveAttributes().size() == 1) {
        for (PrimitiveAttributeDefinition primitive : def.getPrimitiveAttributes()) {
          if (primitive.getSourceName().equals(attributeName)
              || def.getObjectAttributeName().equals(attributeName)) {
            relationship = def;
            minKeys = 1;
            break;
          }
        }
      } else if (def.getPrimitiveAttributes().size() < minKeys) {
        for (PrimitiveAttributeDefinition primitive : def.getPrimitiveAttributes()) {
          if (primitive.getSourceName().equals(attributeName)
              || def.getObjectAttributeName().equals(attributeName)) {
            relationship = def;
            minKeys = def.getPrimitiveAttributes().size();
            break;
          }
        }
      }
    }

    // check the support attributes
    if (relationship == null) {
      for (RelationshipDefinition def : ddRelationships) {
        if (def.hasIdentifier()) {
          if (def.getIdentifier().getSourceName().equals(attributeName)) {
            relationship = def;
          }
        }
      }
    }

    return relationship;
  }
コード例 #17
0
  /**
   * Uses the DataDictionary to determine whether to force uppercase the value, and if it should,
   * then it does the uppercase, and returns the upper-cased value.
   *
   * @param dataObjectClass Parent DO class that the fieldName is a member of.
   * @param fieldName Name of the field to be forced to uppercase.
   * @param fieldValue Value of the field that may be uppercased.
   * @return The correctly uppercased fieldValue if it should be uppercased, otherwise fieldValue is
   *     returned unchanged.
   */
  public static String forceUppercase(
      Class<?> dataObjectClass, String fieldName, String fieldValue) {
    // short-circuit to exit if there isnt enough information to do the forceUppercase
    if (StringUtils.isBlank(fieldValue)) {
      return fieldValue;
    }

    // parameter validation
    if (dataObjectClass == null) {
      throw new IllegalArgumentException("Parameter dataObjectClass passed in with null value.");
    }

    if (StringUtils.isBlank(fieldName)) {
      throw new IllegalArgumentException("Parameter fieldName passed in with empty value.");
    }

    if (!KRADServiceLocatorWeb.getDataDictionaryService()
        .isAttributeDefined(dataObjectClass, fieldName)
        .booleanValue()) {
      return fieldValue;
    }

    boolean forceUpperCase = false;
    try {
      forceUpperCase =
          KRADServiceLocatorWeb.getDataDictionaryService()
              .getAttributeForceUppercase(dataObjectClass, fieldName)
              .booleanValue();
    } catch (UnknownBusinessClassAttributeException ubae) {
      // do nothing, don't alter the fieldValue
    }
    if (forceUpperCase && !fieldValue.endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) {
      return fieldValue.toUpperCase();
    }

    return fieldValue;
  }
コード例 #18
0
  protected List<DocumentAttribute> parsePrimaryKeyValuesFromDocument(
      Class<? extends BusinessObject> businessObjectClass, MaintenanceDocument document) {
    List<DocumentAttribute> values = new ArrayList<DocumentAttribute>();

    final List primaryKeyNames =
        KRADServiceLocatorWeb.getLegacyDataAdapter().listPrimaryKeyFieldNames(businessObjectClass);

    for (Object primaryKeyNameAsObj : primaryKeyNames) {
      final String primaryKeyName = (String) primaryKeyNameAsObj;
      final DocumentAttribute searchableValue =
          parseSearchableAttributeValueForPrimaryKey(primaryKeyName, businessObjectClass, document);
      if (searchableValue != null) {
        values.add(searchableValue);
      }
    }
    return values;
  }
コード例 #19
0
  @Override
  public ActionForward docHandler(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionForward forward = null;

    ProtocolFormBase protocolForm = (ProtocolFormBase) form;
    String command = protocolForm.getCommand();
    String detailId;

    if (command.startsWith(KewApiConstants.DOCSEARCH_COMMAND + "detailId")) {}

    if (KewApiConstants.ACTIONLIST_INLINE_COMMAND.equals(command)) {

    } else if (getProtocolActionsMappingNameHoook().equals(command)
        || getProtocolOnlineReviewMappingNameHoook().equals(command)) {
      String docIdRequestParameter = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
      Document retrievedDocument =
          KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(docIdRequestParameter);
      protocolForm.setDocument(retrievedDocument);
      request.setAttribute(KRADConstants.PARAMETER_DOC_ID, docIdRequestParameter);
      loadDocument(protocolForm);
    } else {
      forward = super.docHandler(mapping, form, request, response);
    }

    if (KewApiConstants.INITIATE_COMMAND.equals(protocolForm.getCommand())) {
      protocolForm.getProtocolDocument().initialize();
    } else {
      protocolForm.initialize();
    }

    if (getProtocolActionsMappingNameHoook().equals(command)) {
      forward = protocolActions(mapping, protocolForm, request, response);
    }
    if (getProtocolOnlineReviewMappingNameHoook().equals(command)) {
      forward = onlineReview(mapping, protocolForm, request, response);
    }

    return forward;
  }
  @Override
  public List<Map<String, String>> resolveMultipleRoleQualifiers(
      @WebParam(name = "kewTypeId") String kewTypeId,
      @WebParam(name = "roleId") String roleId,
      @WebParam(name = "document") Document document,
      @WebParam(name = "documentContent") DocumentContent documentContent) {
    List<Map<String, String>> deptQualifiers = new ArrayList<Map<String, String>>();
    // try to get values from maintainable object if instance of position
    try {
      org.kuali.rice.krad.document.Document doc =
          KRADServiceLocatorWeb.getDocumentService()
              .getByDocumentHeaderId(document.getDocumentId());
      if (doc instanceof MaintenanceDocument) {
        MaintenanceDocument md = (MaintenanceDocument) doc;
        if (md.getNewMaintainableObject().getDataObject() instanceof PositionBo) {
          PositionBo position = (PositionBo) (md.getNewMaintainableObject().getDataObject());

          for (PositionDepartmentBo positionDepartment : position.getDepartmentList()) {
            if (!positionDepartment.getDeptAfflObj().isPrimaryIndicator()) {
              Map<String, String> qualifiers = new HashMap<String, String>();
              qualifiers.put(
                  KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(),
                  String.valueOf(positionDepartment.getDepartment()));
              qualifiers.put(
                  KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(),
                  String.valueOf(positionDepartment.getGroupKeyCode()));
              deptQualifiers.add(qualifiers);
            }
          }
        }
      }
    } catch (WorkflowException e) {
      LOG.error("Unable to retrieve document with documemnt ID: " + document.getDocumentId());
    }

    if (deptQualifiers.isEmpty()) {
      Map<String, String> qualifiers = new HashMap<String, String>();
      qualifiers.put(
          KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), StringUtils.EMPTY);
      qualifiers.put(
          KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), StringUtils.EMPTY);
      deptQualifiers.add(qualifiers);
    }
    return deptQualifiers;
  }
 public ActionForward addPermission(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
   KimDocumentRolePermission newPermission = roleDocumentForm.getPermission();
   if (KRADServiceLocatorWeb.getKualiRuleService()
       .applyRules(
           new AddPermissionEvent("", roleDocumentForm.getRoleDocument(), newPermission))) {
     newPermission.setDocumentNumber(roleDocumentForm.getDocument().getDocumentNumber());
     newPermission.setRoleId(roleDocumentForm.getRoleDocument().getRoleId());
     roleDocumentForm.getRoleDocument().getPermissions().add(newPermission);
     roleDocumentForm.setPermission(new KimDocumentRolePermission());
   }
   return mapping.findForward(RiceConstants.MAPPING_BASIC);
 }
コード例 #22
0
  /**
   * Test the approval of an amendment. Verify that the sequence number has been incremented for the
   * protocol version and that it's status has been set to approved.
   *
   * @throws Exception
   */
  @Test
  public void runAmendmentTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument("0906000003");
    ProtocolSubmitAction submitAction = getMockSubmitAction();

    protocolSubmitActionService.submitToIrbForReview(protocolDocument.getProtocol(), submitAction);

    documentService.routeDocument(protocolDocument, null, null);
    documentService.blanketApproveDocument(protocolDocument, null, null);

    String docNbr =
        protocolAmendRenewService.createAmendment(protocolDocument, getMockProtocolAmendmentBean());

    ProtocolDocument amendmentDocument =
        (ProtocolDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(docNbr);
    protocolSubmitActionService.submitToIrbForReview(amendmentDocument.getProtocol(), submitAction);

    documentService.routeDocument(amendmentDocument, null, null);
    // temporarily disable unit test
    //        documentService.blanketApproveDocument(amendmentDocument, null, null);
    //
    //        assertTrue(getWorkflowDocument(amendmentDocument).isFinal());
    //
    //        Protocol newProtocol =
    // protocolFinder.findCurrentProtocolByNumber(protocolDocument.getProtocol().getProtocolNumber());
    //        assertTrue(newProtocol.getSequenceNumber() ==
    // protocolDocument.getProtocol().getSequenceNumber() + 1);
    //
    //        /*
    //         * Must read the protocol document again in order to obtain the most recent changes.
    //         */
    //        protocolDocument = (ProtocolDocument)
    // documentService.getByDocumentHeaderId(protocolDocument.getDocumentNumber());
    //
    //        assertFalse(protocolDocument.getProtocol().isActive());
    //        assertFalse(amendmentDocument.getProtocol().isActive());
    //        assertTrue(newProtocol.isActive());
    //
    //        // TODO: This test can be re-added once we can route the new protocol through
    // workflow.
    //        //assertEquals(getWorkflowDocument(newProtocol.getProtocolDocument).isFinal());
    //
    //        verifyProtocolAction(newProtocol, ProtocolActionType.APPROVED);
  }
コード例 #23
0
 /**
  * Returns the title at the top of the IWant Document.
  *
  * @return
  */
 public String getHeaderTitle() {
   String iwntTitle = headerTitle;
   if (CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP.equals(step)) {
     iwntTitle =
         "Welcome to the I Want Doc! Submit your order request in just 4 easy steps. <br/>I Want Document Step #1";
   } else if (CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP.equals(step)) {
     iwntTitle = "I Want Document Step #2";
   } else if (CUPurapConstants.IWantDocumentSteps.VENDOR_STEP.equals(step)) {
     iwntTitle = "I Want Document Step #3";
   } else if (CUPurapConstants.IWantDocumentSteps.ROUTING_STEP.equals(step)) {
     iwntTitle = "I Want Document Step #4";
   } else if (CUPurapConstants.IWantDocumentSteps.REGULAR.equals(step)) {
     // iwntTitle = getDocument().getDocumentTitle();
     iwntTitle =
         KRADServiceLocatorWeb.getDataDictionaryService()
             .getDocumentLabelByClass(IWantDocument.class);
   }
   return iwntTitle;
 }
コード例 #24
0
  /**
   * Returns the formatter class to format the substring before it is set on the business object
   *
   * @param parsedObject the object that is being parsed into
   * @return the class for the formatter
   */
  protected Class<?> getFormatterClass(Object parsedObject) {
    if (Formatter.class.isAssignableFrom(formatterClass)) {
      Class<? extends Formatter> attributeFormatter =
          KRADServiceLocatorWeb.getDataDictionaryService()
              .getAttributeFormatter(parsedObject.getClass(), this.propertyName);
      if (attributeFormatter != null) {
        this.formatterClass = attributeFormatter;
      }
    }

    if (!Formatter.class.isAssignableFrom(this.formatterClass)) {
      throw new RuntimeException(
          "formatterClass is not a valid instance of "
              + Formatter.class.getName()
              + " instead was: "
              + formatterClass.getName());
    }
    return formatterClass;
  }
コード例 #25
0
  protected DocumentAttribute generateSearchableAttributeFromChange(Object changeToPersist) {
    List<String> primaryKeyNames =
        KRADServiceLocatorWeb.getLegacyDataAdapter()
            .listPrimaryKeyFieldNames(changeToPersist.getClass());

    for (Object primaryKeyNameAsObject : primaryKeyNames) {
      String primaryKeyName = (String) primaryKeyNameAsObject;
      Object value = ObjectUtils.getPropertyValue(changeToPersist, primaryKeyName);

      if (value != null) {
        final WorkflowAttributePropertyResolutionService propertyResolutionService =
            KNSServiceLocator.getWorkflowAttributePropertyResolutionService();
        DocumentAttribute saValue =
            propertyResolutionService.buildSearchableAttribute(
                (Class) changeToPersist.getClass(), primaryKeyName, value);
        return saValue;
      }
    }
    return null;
  }
コード例 #26
0
  /**
   * This method gets called upon navigation to ProtocolBase Actions tab.
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   */
  public ActionForward protocolActions(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // for protocol lookup copy link - rice 1.1 need this
    ProtocolFormBase protocolForm = (ProtocolFormBase) form;
    String command = request.getParameter("command");
    if (KewApiConstants.DOCSEARCH_COMMAND.equals(command)) {
      String docIdRequestParameter = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
      Document retrievedDocument =
          KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(docIdRequestParameter);
      protocolForm.setDocument(retrievedDocument);
      request.setAttribute(KRADConstants.PARAMETER_DOC_ID, docIdRequestParameter);
    }
    // make sure current submission is displayed when navigate to action page.
    protocolForm.getActionHelper().setCurrentSubmissionNumber(-1);
    protocolForm.getActionHelper().prepareView();
    protocolForm.getActionHelper().prepareCommentsView();

    // When a user selects the Questionnaires tab, empty answerHeaders are generated and saved to
    // the database so that subsequent methods relying
    // on that persisted data have it available to render panels.  Make Protocol Actions tab work in
    // this same manner so it's sub-tab
    // Print ==> Questionnaires will render when a user enters a protocol but does not select the
    // Questionnaire tab to answer the questions.
    protocolForm.getQuestionnaireHelper().prepareView();
    protocolForm.getQuestionnaireHelper().populateAnswers();
    protocolForm.getQuestionnaireHelper().setQuestionnaireActiveStatuses();
    Document document = protocolForm.getDocument();
    List<AnswerHeader> answerHeaders = protocolForm.getQuestionnaireHelper().getAnswerHeaders();
    if (applyRules(new SaveQuestionnaireAnswerEvent(document, answerHeaders))
        && applyRules(new SaveProtocolQuestionnaireEvent(document, answerHeaders))) {
      protocolForm.getQuestionnaireHelper().preSave();
      getBusinessObjectService().save(answerHeaders);
    }

    return branchToPanelOrNotificationEditor(
        mapping, protocolForm, getProtocolActionsForwardNameHook());
  }
  @Override
  public ProposalDevelopmentDocument createProposalDevelopmentDocument(ProtocolForm protocolForm)
      throws Exception {
    ProposalDevelopmentDocument proposalDevelopmentDocument = null;
    Protocol protocol = protocolForm.getProtocolDocument().getProtocol();
    if (isAuthorizedCreateProposal(protocolForm.getProtocolHelper())) {
      DocumentService docService = KRADServiceLocatorWeb.getDocumentService();
      proposalDevelopmentDocument =
          (ProposalDevelopmentDocument)
              docService.getNewDocument(ProposalDevelopmentDocument.class);
      ProposalDevelopmentService proposalDevelopmentService =
          KraServiceLocator.getService(ProposalDevelopmentService.class);
      populateDocumentOverview(protocol, proposalDevelopmentDocument);
      populateRequiredFields(protocol, proposalDevelopmentDocument);
      proposalDevelopmentService.initializeUnitOrganizationLocation(proposalDevelopmentDocument);
      proposalDevelopmentService.initializeProposalSiteNumbers(proposalDevelopmentDocument);
      populateProposalPerson_Investigator(protocol, proposalDevelopmentDocument);
      populateProposalSpecialReview(protocol, proposalDevelopmentDocument);

      docService.saveDocument(proposalDevelopmentDocument);
      initializeAuthorization(proposalDevelopmentDocument);
    }
    return proposalDevelopmentDocument;
  }
コード例 #28
0
  @Override
  public Document recallDocument(Document document, String annotation, boolean cancel)
      throws WorkflowException {
    checkForNulls(document);
    WorkflowDocument workflowDocument =
        KRADServiceLocatorWeb.getDocumentService()
            .getByDocumentHeaderId(document.getDocumentNumber())
            .getDocumentHeader()
            .getWorkflowDocument();

    if (!workflowDocument.isFinal() && !workflowDocument.isProcessed()) {
      Note note = createNoteFromDocument(document, annotation);
      document.addNote(note);
      getNoteService().save(note);
    }

    prepareWorkflowDocument(document);
    getWorkflowDocumentService()
        .recall(document.getDocumentHeader().getWorkflowDocument(), annotation, cancel);
    UserSessionUtils.addWorkflowDocument(
        GlobalVariables.getUserSession(), document.getDocumentHeader().getWorkflowDocument());
    removeAdHocPersonsAndWorkgroups(document);
    return document;
  }
 private LookupService getLookupService() {
   return KRADServiceLocatorWeb.getLookupService();
 }
コード例 #30
0
  /**
   * Invoked to request an inquiry view for a data object class
   *
   * <p>Checks if the data object is externalizable and we need to redirect to the appropriate
   * inquiry URL, else continues with the inquiry view display
   *
   * <p>Data object class name and values for a primary or alternate key set must be sent in the
   * request
   *
   * <p>Invokes the inquirable to perform the query for the data object record, if not found an
   * exception will be thrown. If found the object is set on the form and then the view is rendered
   */
  @RequestMapping(params = "methodToCall=start")
  @Override
  public ModelAndView start(
      @ModelAttribute("KualiForm") UifFormBase form,
      BindingResult result,
      HttpServletRequest request,
      HttpServletResponse response) {
    InquiryForm inquiryForm = (InquiryForm) form;

    // if request is not a redirect, determine if we need to redirect for an externalizable object
    // inquiry
    if (!inquiryForm.isRedirectedInquiry()) {
      Class inquiryObjectClass = null;
      try {
        inquiryObjectClass = Class.forName(inquiryForm.getDataObjectClassName());
      } catch (ClassNotFoundException e) {
        throw new RiceRuntimeException(
            "Unable to get class for name: " + inquiryForm.getDataObjectClassName());
      }

      ModuleService responsibleModuleService =
          KRADServiceLocatorWeb.getKualiModuleService()
              .getResponsibleModuleService(inquiryObjectClass);
      if (responsibleModuleService != null
          && responsibleModuleService.isExternalizable(inquiryObjectClass)) {
        String inquiryUrl =
            responsibleModuleService.getExternalizableDataObjectInquiryUrl(
                inquiryObjectClass,
                KRADUtils.convertRequestMapToProperties(request.getParameterMap()));

        Properties redirectUrlProps = new Properties();
        redirectUrlProps.put(UifParameters.REDIRECTED_INQUIRY, "true");

        // clear current form from session
        GlobalVariables.getUifFormManager().removeSessionForm(form);

        return performRedirect(form, inquiryUrl, redirectUrlProps);
      }
    }

    // initialize data object class in inquirable
    try {
      inquiryForm
          .getInquirable()
          .setDataObjectClass(Class.forName(inquiryForm.getDataObjectClassName()));
    } catch (ClassNotFoundException e) {
      LOG.error(
          "Unable to get new instance for object class: " + inquiryForm.getDataObjectClassName(),
          e);
      throw new RuntimeException(
          "Unable to get new instance for object class: " + inquiryForm.getDataObjectClassName(),
          e);
    }

    // invoke inquirable to retrieve inquiry data object
    Object dataObject =
        inquiryForm
            .getInquirable()
            .retrieveDataObject(KRADUtils.translateRequestParameterMap(request.getParameterMap()));

    inquiryForm.setDataObject(dataObject);

    return super.start(form, result, request, response);
  }