Merged up to HEAD.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3129 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-06-16 19:18:30 +00:00
parent 77df6eb45d
commit d2f8666983
39 changed files with 2129 additions and 1142 deletions

View File

@@ -0,0 +1,34 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.web.bean.actions.IHandler;
/**
* Base class for all condition handler implementations.
*
* @author gavinc
*/
public abstract class BaseConditionHandler implements IHandler
{
protected static final String CONDITION_PAGES_LOCATION = "/jsp/rules/";
public static final String PROP_CONDITION_NOT = "notcondition";
public void setupUIDefaults(Map<String, Serializable> conditionProps)
{
// do nothing by default, only those condition handlers that need
// to setup defaults need override this method
}
/**
* Given the condition name, generates the default path for the JSP
*
* @param conditionName The name of the condition
* @return The path to the JSP used for the condition
*/
protected String getJSPPath(String conditionName)
{
return CONDITION_PAGES_LOCATION + conditionName + ".jsp";
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.evaluator.CompareMimeTypeEvaluator;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.rules.CreateRuleWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "compare-mime-type" condition
*
* @author gavinc
*/
public class CompareMimeTypeHandler extends BaseConditionHandler
{
protected static final String PROP_MIMETYPE = "mimetype";
public String getJSPPath()
{
return getJSPPath(CompareMimeTypeEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String mimeType = (String)conditionProps.get(PROP_MIMETYPE);
repoProps.put(CompareMimeTypeEvaluator.PARAM_VALUE, mimeType);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String mimeType = (String)repoProps.get(CompareMimeTypeEvaluator.PARAM_VALUE);
conditionProps.put(PROP_MIMETYPE, mimeType);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_compare_mime_type_not" : "condition_compare_mime_type";
String label = null;
String mimetype = (String)conditionProps.get(PROP_MIMETYPE);
for (SelectItem item : ((CreateRuleWizard)wizard).getMimeTypes())
{
if (item.getValue().equals(mimetype))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
}

View File

@@ -0,0 +1,64 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.evaluator.HasAspectEvaluator;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.rules.CreateRuleWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "has-aspect" condition.
*
* @author gavinc
*/
public class HasAspectHandler extends BaseConditionHandler
{
protected static final String PROP_ASPECT = "aspect";
public String getJSPPath()
{
return getJSPPath(HasAspectEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName aspect = QName.createQName((String)conditionProps.get(PROP_ASPECT));
repoProps.put(HasAspectEvaluator.PARAM_ASPECT, aspect);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName aspect = (QName)repoProps.get(HasAspectEvaluator.PARAM_ASPECT);
conditionProps.put(PROP_ASPECT, aspect.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_has_aspect_not" : "condition_has_aspect";
String label = null;
String aspectName = (String)conditionProps.get(PROP_ASPECT);
for (SelectItem item : ((CreateRuleWizard)wizard).getAspects())
{
if (item.getValue().equals(aspectName))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
}

View File

@@ -0,0 +1,61 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.evaluator.InCategoryEvaluator;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "in-category" condition.
*
* @author gavinc
*/
public class InCategoryHandler extends BaseConditionHandler
{
protected static final String PROP_CATEGORY = "category";
public String getJSPPath()
{
return getJSPPath(InCategoryEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
// put the selected category in the condition params
NodeRef nodeRef = (NodeRef)conditionProps.get(PROP_CATEGORY);
repoProps.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, nodeRef);
// add the classifiable aspect
repoProps.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT,
ContentModel.ASPECT_GEN_CLASSIFIABLE);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
NodeRef catNodeRef = (NodeRef)repoProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE);
conditionProps.put(PROP_CATEGORY, catNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_in_category_not" : "condition_in_category";
String name = Repository.getNameForNode(Repository.getServiceRegistry(context).
getNodeService(), (NodeRef)conditionProps.get(PROP_CATEGORY));
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {name});
}
}

View File

@@ -0,0 +1,64 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.rules.CreateRuleWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler to the "is-subtype" condition.
*
* @author gavinc
*/
public class IsSubTypeHandler extends BaseConditionHandler
{
protected static final String PROP_MODEL_TYPE = "modeltype";
public String getJSPPath()
{
return getJSPPath(IsSubTypeEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName type = QName.createQName((String)conditionProps.get(PROP_MODEL_TYPE));
repoProps.put(IsSubTypeEvaluator.PARAM_TYPE, type);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName type = (QName)repoProps.get(IsSubTypeEvaluator.PARAM_TYPE);
conditionProps.put(PROP_MODEL_TYPE, type.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_is_subtype_not" : "condition_is_subtype";
String label = null;
String typeName = (String)conditionProps.get(PROP_MODEL_TYPE);
for (SelectItem item : ((CreateRuleWizard)wizard).getModelTypes())
{
if (item.getValue().equals(typeName))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
}

View File

@@ -0,0 +1,53 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "compare-property-value" condition.
*
* @author gavinc
*/
public class PropertyValueHandler extends BaseConditionHandler
{
public static final String PROP_CONTAINS_TEXT = "containstext";
public String getJSPPath()
{
return getJSPPath(ComparePropertyValueEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String text = (String)conditionProps.get(PROP_CONTAINS_TEXT);
repoProps.put(ComparePropertyValueEvaluator.PARAM_VALUE, text);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String propValue = (String)repoProps.get(ComparePropertyValueEvaluator.PARAM_VALUE);
conditionProps.put(PROP_CONTAINS_TEXT, propValue);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ?
"condition_compare_property_value_not" : "condition_compare_property_value";
String text = (String)conditionProps.get(PROP_CONTAINS_TEXT);
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {text});
}
}