protected static DocumentDictionaryService getDocumentDictionaryService() { if (documentDictionaryService == null) { documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); } return documentDictionaryService; }
@Override public boolean canCreate(Class boClass) { return KRADServiceLocatorWeb.getDocumentDictionaryService().getAllowsNewOrCopy( KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentTypeName(boClass)); }
protected List<PositionContract> filterLookupPositions(List<PositionContract> rawResults) { DocumentDictionaryService documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); List<PositionContract> results = new ArrayList<PositionContract>(); for (PositionContract positionObj : rawResults) { if ( ((PositionDocumentAuthorizer)(documentDictionaryService.getDocumentAuthorizer(this.getMaintenanceDocumentTypeName()))).canView(positionObj, GlobalVariables.getUserSession().getPerson()) ) { results.add(positionObj); } } return results; }
protected boolean canEdit(MaintenanceDocument document) { DocumentAuthorizer auth = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentAuthorizer(document); boolean valid = true; if (auth != null) { valid = auth.canEdit(document, GlobalVariables.getUserSession().getActualPerson()); } if (!valid) { this.putFieldError("dataObject.primaryDepartment", "error.primaryDepartment.invalid"); } return valid; }
@Override public void getMaintenanceActionLink(Action actionLink, Object model, String maintenanceMethodToCall) { super.getMaintenanceActionLink(actionLink, model, maintenanceMethodToCall); if (StringUtils.equals(actionLink.getActionLabel(), "copy")) { DocumentDictionaryService documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); Map<String, Object> context = actionLink.getContext(); PositionBo bo = ((PositionBo)context.get((String)"line")); if ( ! (((PositionDocumentAuthorizer)(documentDictionaryService.getDocumentAuthorizer(this.getMaintenanceDocumentTypeName()))).canCopy(bo, GlobalVariables.getUserSession().getPerson())) ) { actionLink.setRender(false); return; } } } }
public List<TimeCollectionRule> getTimeCollectionRules(String userPrincipalId, List <TimeCollectionRule> timeCollectionRuleObjs){ List<TimeCollectionRule> results = new ArrayList<TimeCollectionRule>(); if ( timeCollectionRuleObjs != null ){ for (TimeCollectionRule timeCollectionRuleObj : timeCollectionRuleObjs) { String department = timeCollectionRuleObj.getDept(); String grpKeyCode = timeCollectionRuleObj.getGroupKeyCode(); Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department, grpKeyCode, timeCollectionRuleObj.getEffectiveLocalDate()); String location = departmentObj != null ? departmentObj.getGroupKey().getLocationId() : null; Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentTypeName(TimeCollectionRule.class)); Map<String, String> roleQualification = new HashMap<String, String>(); roleQualification.put(KimConstants.AttributeConstants.PRINCIPAL_ID, userPrincipalId); roleQualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department); roleQualification.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), grpKeyCode); roleQualification.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), location); if (!KimApiServiceLocator.getPermissionService().isPermissionDefinedByTemplate(KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails) || KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(userPrincipalId, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails, roleQualification)) { results.add(timeCollectionRuleObj); } } } return results; } }
@Override public boolean isAuthorizedForDocument(String principalId, Document document) { try { MissedPunchDocument mpd = (MissedPunchDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(document.getDocumentId()); String groupKey = mpd.getGroupKeyCode(); Long workArea = mpd.getWorkArea(); String department = mpd.getDepartment(); String location = mpd.getGroupKey() != null ? mpd.getGroupKey().getLocationId() : HrServiceLocator.getHrGroupKeyService().getHrGroupKey(mpd.getGroupKeyCode(), mpd.getMissedPunch().getActionLocalDate()).getLocationId(); Map<String, String> roleQualification = new HashMap<String, String>(); roleQualification.put(KimConstants.AttributeConstants.PRINCIPAL_ID, principalId); roleQualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department); roleQualification.put(KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(), workArea.toString()); roleQualification.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), groupKey); roleQualification.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), location); Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentTypeByClass(MissedPunchDocument.class)); return (!KimApiServiceLocator.getPermissionService().isPermissionDefinedByTemplate(KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), new HashMap<String, String>()) || KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(principalId, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails, roleQualification)); } catch (WorkflowException e) { return false; } } }
@Override public boolean canCopy(Document document) { Maintainable obj = ((MaintenanceDocumentBase) document).getNewMaintainableObject(); //((MaintenanceDocumentBase) document).getDocumentHeader().ge DocumentDictionaryService documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); boolean canCopy = false; if (document.getAllowsCopy()) { canCopy = true; } if (!(((PositionDocumentAuthorizer)(documentDictionaryService.getDocumentAuthorizer((String)"PositionMaintenanceDocumentType"))).canCopy(obj.getDataObject(), GlobalVariables.getUserSession().getPerson()))) { canCopy = false; } return canCopy; } }
permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentTypeByClass(MissedPunchDocument.class));