mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2448 (Extend classified document properties view)
RM-2449 (Extend classified record properties view) +review RM-137 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@109139 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound;
|
||||
|
||||
@@ -80,6 +81,15 @@ public interface ClassificationSchemeService
|
||||
*/
|
||||
List<ExemptionCategory> getExemptionCategories();
|
||||
|
||||
/**
|
||||
* Gets the exemption category for the given exemption category id
|
||||
*
|
||||
* @param exemptionCategoryId {@link String} The exemption category id for which the exemption category should be retrieved.
|
||||
* @return The exemption category for the given exemption category id
|
||||
* @throws ExemptionCategoryIdNotFound If the given exemption id is not found
|
||||
*/
|
||||
ExemptionCategory getExemptionCategoryById(String exemptionCategoryId) throws ExemptionCategoryIdNotFound;
|
||||
|
||||
/**
|
||||
* Identifies the reclassification type for the provided pair of {@link ClassificationLevel levels}.
|
||||
*
|
||||
|
@@ -19,7 +19,6 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -27,6 +26,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ExemptionCategoryIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.ReasonIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
|
||||
@@ -162,4 +162,14 @@ public class ClassificationSchemeServiceImpl extends ServiceBaseImpl implements
|
||||
}
|
||||
return unmodifiableSet(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService#getExemptionCategoryById(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ExemptionCategory getExemptionCategoryById(String exemptionCategoryId) throws ExemptionCategoryIdNotFound
|
||||
{
|
||||
checkNotBlank("exemptionCategoryId", exemptionCategoryId);
|
||||
return exemptionCategoryManager.findCategoryById(exemptionCategoryId);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.jscript.app;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ExemptionCategory;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONAware;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* Exemption categories property decorator
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0.a
|
||||
*/
|
||||
public class ExemptionsCategoriesPropertyDecorator extends BasePropertyDecorator
|
||||
{
|
||||
/** Constants */
|
||||
protected static final String ID = "id";
|
||||
protected static final String LABEL = "label";
|
||||
protected static final String VALUE = "value";
|
||||
protected static final String DISPLAY_LABEL = "displayLabel";
|
||||
protected static final String FULL_CATEGORY = "fullCategory";
|
||||
|
||||
/** Classification scheme service */
|
||||
private ClassificationSchemeService classificationSchemeService;
|
||||
|
||||
/**
|
||||
* @return the classificationSchemeService
|
||||
*/
|
||||
protected ClassificationSchemeService getClassificationSchemeService()
|
||||
{
|
||||
return this.classificationSchemeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classificationSchemeService the classificationSchemeService to set
|
||||
*/
|
||||
public void setClassificationSchemeService(ClassificationSchemeService classificationSchemeService)
|
||||
{
|
||||
this.classificationSchemeService = classificationSchemeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value)
|
||||
{
|
||||
mandatory("value", value);
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONArray exemptionCategoryIds = new JSONArray();
|
||||
|
||||
if (value instanceof String)
|
||||
{
|
||||
exemptionCategoryIds = new Gson().fromJson((String) value, JSONArray.class);
|
||||
}
|
||||
else if (value instanceof List)
|
||||
{
|
||||
List<String> values = (List<String>) value;
|
||||
for (String exemptionCategoryId : values)
|
||||
{
|
||||
exemptionCategoryIds.add(exemptionCategoryId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unexpected value instance: '" + value + "'.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < exemptionCategoryIds.size(); i++)
|
||||
{
|
||||
String exemptionCategoryId = (String) exemptionCategoryIds.get(i);
|
||||
ExemptionCategory exemptionCategory = getClassificationSchemeService().getExemptionCategoryById(exemptionCategoryId);
|
||||
String exemptionCategoryDisplayLabel = exemptionCategory.getDisplayLabel();
|
||||
String exemptionCategoryFullCategory = exemptionCategoryId + ": " + exemptionCategoryDisplayLabel;
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put(ID, exemptionCategoryId);
|
||||
jsonObject.put(LABEL, exemptionCategoryFullCategory);
|
||||
jsonObject.put(VALUE, exemptionCategoryId);
|
||||
jsonObject.put(DISPLAY_LABEL, exemptionCategoryDisplayLabel);
|
||||
jsonObject.put(FULL_CATEGORY, exemptionCategoryFullCategory);
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user