permissionDetails = new HashMap();
permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME,
documentTypeName);
return getPermissionService().isAuthorizedByTemplateName(
user.getPrincipalId(), nameSpaceCode,
KimConstants.PermissionTemplateNames.INITIATE_DOCUMENT,
permissionDetails, Collections.emptyMap());
}
public final boolean canReceiveAdHoc(Document document, Person user,
String actionRequestCode) {
Map additionalPermissionDetails = new HashMap();
additionalPermissionDetails.put(KimConstants.AttributeConstants.ACTION_REQUEST_CD, actionRequestCode);
return isAuthorizedByTemplate(document,
KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE,
KimConstants.PermissionTemplateNames.AD_HOC_REVIEW_DOCUMENT,
user.getPrincipalId(), additionalPermissionDetails, null );
]]>
attributes) {
super.addPermissionDetails(dataObject, attributes);
if (dataObject instanceof Document) {
addStandardAttributes((Document) dataObject, attributes);
}
}
@Override
protected void addRoleQualification(Object dataObject,
Map attributes) {
super.addRoleQualification(dataObject, attributes);
if (dataObject instanceof Document) {
addStandardAttributes((Document) dataObject, attributes);
}
}
protected void addStandardAttributes(Document document,
Map attributes) {
WorkflowDocument wd = document.getDocumentHeader()
.getWorkflowDocument();
attributes.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, document
.getDocumentNumber());
attributes.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, wd.getDocumentTypeName());
if (wd.isInitiated() || wd.isSaved()) {
attributes.put(KimConstants.AttributeConstants.ROUTE_NODE_NAME,
PRE_ROUTING_ROUTE_NAME);
} else {
attributes.put(KimConstants.AttributeConstants.ROUTE_NODE_NAME, KRADServiceLocatorWeb.getWorkflowDocumentService().getCurrentRouteNodeNames(wd));
}
attributes.put(KimConstants.AttributeConstants.ROUTE_STATUS_CODE, wd.getStatus().getCode());
}
protected boolean isDocumentInitiator(Document document, Person user) {
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
return workflowDocument.getInitiatorPrincipalId().equalsIgnoreCase(user.getPrincipalId());
}
}
]]>
additionalPermissionDetails = new HashMap();
additionalPermissionDetails.put(KimConstants.AttributeConstants.ACTION_REQUEST_CD,
actionRequestCode);
return isAuthorizedByTemplate(document, KRADConstants.KRAD_NAMESPACE,
KimConstants.PermissionTemplateNames.TAKE_REQUESTED_ACTION,
user.getPrincipalId(), additionalPermissionDetails, null);
]]>
> Object getVal(U toConv) {
Object o = toConv.getValue();
if (o instanceof DateTime) {
return new Timestamp(((DateTime) o).getMillis());
}
return o;
}
//this is unsafe b/c values could be converted resulting in a classcast exception
@SuppressWarnings("unchecked")
private static > Set getValsUnsafe(Set extends U> toConv) {
return (Set) getVals(toConv);
}
private static Set> getVals(Set extends CriteriaValue>> toConv) {
final Set
(getPermissionDetailValues(dataObject));
}
return getPermissionService().isAuthorized(principalId, namespaceCode, permissionName,
permissionDetails, roleQualifiers);
}
public final boolean isAuthorizedByTemplate(Object dataObject, String namespaceCode, String permissionTemplateName,
String principalId, Map collectionOrFieldLevelPermissionDetails,
Map collectionOrFieldLevelRoleQualification) {
Map roleQualifiers = new HashMap(getRoleQualification(dataObject, principalId));
Map permissionDetails = new HashMap(getPermissionDetailValues(dataObject));
if (collectionOrFieldLevelRoleQualification != null) {
roleQualifiers.putAll(collectionOrFieldLevelRoleQualification);
}
if (collectionOrFieldLevelPermissionDetails != null) {
permissionDetails.putAll(collectionOrFieldLevelPermissionDetails);
}
return getPermissionService().isAuthorizedByTemplateName(principalId, namespaceCode,
permissionTemplateName, permissionDetails, roleQualifiers);
}
/**
* Returns a role qualification map based off data from the primary business
* object or the document. DO NOT MODIFY THE MAP RETURNED BY THIS METHOD
*
* @param primaryDataObjectOrDocument
* the primary data object (i.e. the main object instance behind
* the lookup result row or inquiry) or the document
* @return a Map containing role qualifications
*/
protected final Map getRoleQualification(Object primaryDataObjectOrDocument) {
]]>
criteria.getMaxResults()) {
results.setMoreResultsAvailable(true);
//remove the extra row that was returned
rows.remove(criteria.getMaxResults().intValue());
}
results.setResults(transformResults(rows, transform));
return results.build();
}
private static List transformResults(List results, LookupCustomizer.Transform transform) {
final List list = new ArrayList();
for (T r : results) {
list.add(transform.apply(r));
}
return list;
}
/** gets results where only the count is requested. */
private GenericQueryResults forCountOnly(final Class queryClass, final QueryByCriteria criteria, final Criteria ojbCriteria) {
]]>
queryParameters = new HashMap();
for (Object parameterName : request.getParameterMap().keySet()) {
if (parameterName.toString().startsWith(UifParameters.QUERY_PARAMETER + ".")) {
String fieldName = StringUtils.substringAfter(parameterName.toString(),
UifParameters.QUERY_PARAMETER + ".");
String fieldValue = request.getParameter(parameterName.toString());
queryParameters.put(fieldName, fieldValue);
}
}
// retrieve id for field to perform query for
String queryFieldId = request.getParameter(UifParameters.QUERY_FIELD_ID);
if (StringUtils.isBlank(queryFieldId)) {
throw new RuntimeException("Unable to find id for field to perform query on under request parameter name: "
+ UifParameters.QUERY_FIELD_ID);
}
]]>
GenericQueryResults forRowResults(final Class queryClass, final QueryByCriteria criteria, final Criteria ojbCriteria, CountFlag flag, LookupCustomizer.Transform transform) {
]]>
GenericQueryResults lookup(final Class queryClass, final QueryByCriteria criteria) {
return lookup(queryClass, criteria, LookupCustomizer.Builder.create().build());
}
@Override
public GenericQueryResults lookup(final Class queryClass, final QueryByCriteria criteria, LookupCustomizer customizer) {
if (queryClass == null) {
throw new IllegalArgumentException("queryClass is null");
}
if (criteria == null) {
throw new IllegalArgumentException("criteria is null");
}
if (customizer == null) {
throw new IllegalArgumentException("customizer is null");
}
final Criteria parent = new Criteria();
]]>
();
}
/**
* The number of property elements in this state object.
*
* @return
*/
public int numPropertyElements() {
return pathElements.size();
}
/**
* Adds an additional state element into this object.
*
* @param elementName
* @param propertyType the type of the property when it was serialized
*/
public void addSerializedProperty(String elementName, PropertyType propertyType) {
SerializationPropertyElement serializationPropertyElement = new SerializationPropertyElement(elementName, propertyType);
pathElements.add(serializationPropertyElement);
}
/**
* Removes the last added serialized property
*
*/
public void removeSerializedProperty() {
pathElements.remove(pathElements.size() - 1);
}
/**
* Retrieves the element name of the state element. A parameter value of 0 represents the first element that was added
* by calling {@link #addSerializedProperty(String, PropertyType)} that hasn't been removed, and a value of
* {@link #numPropertyElements()} - 1 represents the element last added that hasn't been removed.
*
* @param propertyIndex most be between 0 and the value returned by {@link #numPropertyElements()} - 1
* @return
*/
public String getElementName(int propertyIndex) {
return pathElements.get(propertyIndex).getElementName();
}
/**
* Retrieves the property type of the state element. A parameter value of 0 represents the first element that was added
* by calling {@link #addSerializedProperty(String, PropertyType)} that hasn't been removed, and a value of
* {@link #numPropertyElements()} - 1 represents the element last added that hasn't been removed.
*
* @param propertyIndex most be between 0 and the value returned by {@link #numPropertyElements()} - 1
* @return
*/
public PropertyType getPropertyType(int propertyIndex) {
return pathElements.get(propertyIndex).getPropertyType();
}
}
]]>
additionalPermissionDetails = new HashMap();
if (attachmentTypeCode != null) {
additionalPermissionDetails.put(KimConstants.AttributeConstants.ATTACHMENT_TYPE_CODE,
attachmentTypeCode);
}
return isAuthorizedByTemplate(document, KRADConstants.KRAD_NAMESPACE,
KimConstants.PermissionTemplateNames.ADD_NOTE_ATTACHMENT, user
.getPrincipalId(), additionalPermissionDetails, null);
]]>