Merged V3.1 to HEAD

14628: Second attempt at ETHREEOH-2144 fix - tested against several known good webforms.
   14854: Fix for ETHREEOH-2206. Also fixes minor issue where rule condition selection box was not reset after adding a condition to a composite.
   14862: Fix for ETHREEOH-1946 - correctly coerce nodes returned from javascript into AVMTemplateNode objects if they are AVM NodeRef objects.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14864 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-06-23 14:34:50 +00:00
parent 272a2812c1
commit e470d63e36
3 changed files with 60 additions and 32 deletions

View File

@@ -55,16 +55,18 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
// This limitation is introduced by the fact that we are have two "current" // This limitation is introduced by the fact that we are have two "current"
// conditions - either normal condition, or composite conditions // conditions - either normal condition, or composite conditions
// basically, the UI will have to store conditions in a more native way // basically, the UI will have to store conditions in a more native way
// (instead of DataModel) to get unlimited number of composite conditions // (instead of DataModel) to get unlimited number of composite conditions recursing
// recursing
protected DataModel currentCompositeConditionsDataModel; protected DataModel currentCompositeConditionsDataModel;
protected List<Map<String, Serializable>> currentCompositeConditionPropertiesList; protected List<Map<String, Serializable>> currentCompositeConditionPropertiesList;
private boolean addingCompositeCondition; private boolean addingCompositeCondition;
private boolean editCurrentCompositeCondition;
private int rowIndex = -1;
public CreateCompositeRuleWizard() public CreateCompositeRuleWizard()
{ {
// TODO Auto-generated constructor stub
} }
@Override @Override
@@ -75,7 +77,6 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
this.setAddingCompositeCondition(false); this.setAddingCompositeCondition(false);
this.currentCompositeConditionsDataModel = null; this.currentCompositeConditionsDataModel = null;
this.currentCompositeConditionPropertiesList = null; this.currentCompositeConditionPropertiesList = null;
} }
public void setupCompositeConditionsMode() public void setupCompositeConditionsMode()
@@ -83,7 +84,6 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
this.setAddingCompositeCondition(true); this.setAddingCompositeCondition(true);
this.currentCompositeConditionsDataModel = new ListDataModel(); this.currentCompositeConditionsDataModel = new ListDataModel();
this.currentCompositeConditionPropertiesList = new ArrayList<Map<String, Serializable>>(); this.currentCompositeConditionPropertiesList = new ArrayList<Map<String, Serializable>>();
} }
private void clearCompositeConditionMode() private void clearCompositeConditionMode()
@@ -94,7 +94,6 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
this.currentCompositeConditionsDataModel = null; this.currentCompositeConditionsDataModel = null;
this.currentCompositeConditionPropertiesList = null; this.currentCompositeConditionPropertiesList = null;
this.setAddingCompositeCondition(false); this.setAddingCompositeCondition(false);
} }
/** /**
@@ -147,10 +146,7 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
IHandler handler = this.conditionHandlers.get(this.selectedCondition); IHandler handler = this.conditionHandlers.get(this.selectedCondition);
// creating object temporarily so we can pass it to // creating object temporarily so we can pass it to CompositeConditionHandler
// CompositeConditionHandler
// Map<String, Serializable> newCompositeCondition = new HashMap<String,
// Serializable>();
currentConditionProperties.put(CompositeConditionHandler.PROP_COMPOSITE_CONDITION, currentConditionProperties.put(CompositeConditionHandler.PROP_COMPOSITE_CONDITION,
(Serializable) this.currentCompositeConditionPropertiesList); (Serializable) this.currentCompositeConditionPropertiesList);
currentConditionProperties.put(PROP_CONDITION_NAME, this.selectedCondition); currentConditionProperties.put(PROP_CONDITION_NAME, this.selectedCondition);
@@ -165,11 +161,22 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Generated Summary - [" + summary + "] + selectedCondition " + this.selectedCondition); logger.debug("Generated Summary - [" + summary + "] + selectedCondition " + this.selectedCondition);
if (editingCondition == false) if (this.editCurrentCompositeCondition == true)
{
if (rowIndex != -1)
{
this.allConditionsPropertiesList.remove(rowIndex);
this.allConditionsPropertiesList.add(rowIndex, currentConditionProperties);
}
}
else
{ {
this.allConditionsPropertiesList.add(currentConditionProperties); this.allConditionsPropertiesList.add(currentConditionProperties);
} }
this.editCurrentCompositeCondition = false;
this.rowIndex = -1;
clearCompositeConditionMode(); clearCompositeConditionMode();
// refresh the wizard // refresh the wizard
goToPage(context, this.returnViewId); goToPage(context, this.returnViewId);
@@ -194,6 +201,8 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
@Override @Override
public void cancelAddCondition() public void cancelAddCondition()
{ {
this.editCurrentCompositeCondition = false;
this.rowIndex = -1;
if (isAddingCompositeCondition()) if (isAddingCompositeCondition())
{ {
// don't clear when editing, since we are looking at a REFERENCE to an existing condition // don't clear when editing, since we are looking at a REFERENCE to an existing condition
@@ -224,7 +233,6 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
super.cancelAddCondition(); super.cancelAddCondition();
return; return;
} }
} }
/** /**
@@ -274,7 +282,6 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("\tEdited composite condition. "); logger.debug("\tEdited composite condition. ");
//editingCondition = false;
} }
this.currentConditionProperties = new HashMap<String, Serializable>(3); this.currentConditionProperties = new HashMap<String, Serializable>(3);
@@ -284,10 +291,12 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
this.currentConditionProperties.put(PROP_CONDITION_NAME, CompositeConditionHandler.NAME); this.currentConditionProperties.put(PROP_CONDITION_NAME, CompositeConditionHandler.NAME);
this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE); this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
// reset the action drop down
this.selectedCondition = null;
// refresh the wizard // refresh the wizard
printConditionState(); printConditionState();
goToPage(context, this.returnViewId); goToPage(context, this.returnViewId);
} }
/** /**
@@ -305,6 +314,8 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
if (!isAddingCompositeCondition()) if (!isAddingCompositeCondition())
{ {
Map condition = (Map) this.allConditionsDataModel.getRowData(); Map condition = (Map) this.allConditionsDataModel.getRowData();
this.rowIndex = this.allConditionsDataModel.getRowIndex();
this.editCurrentCompositeCondition = true;
if (condition.get(PROP_CONDITION_NAME).equals(CompositeConditionHandler.NAME)) if (condition.get(PROP_CONDITION_NAME).equals(CompositeConditionHandler.NAME))
{ {
@@ -322,8 +333,6 @@ public class CreateCompositeRuleWizard extends CreateRuleWizard
super.editCondition(subCondition); super.editCondition(subCondition);
} }
} }
public List<SelectItem> getCompositeConditions() public List<SelectItem> getCompositeConditions()
{ {

View File

@@ -22,27 +22,42 @@
* http://www.alfresco.com/legal/licensing" */ * http://www.alfresco.com/legal/licensing" */
package org.alfresco.web.forms; package org.alfresco.web.forms;
import freemarker.ext.dom.NodeModel; import java.io.IOException;
import freemarker.cache.TemplateLoader; import java.io.InputStream;
import freemarker.template.*; import java.io.InputStreamReader;
import java.io.*; import java.io.OutputStream;
import java.util.*; import java.io.OutputStreamWriter;
import javax.xml.parsers.DocumentBuilder; import java.io.Reader;
import org.alfresco.model.ContentModel; import java.util.Date;
import org.alfresco.service.cmr.repository.ContentReader; import java.util.LinkedList;
import org.alfresco.service.cmr.repository.ContentService; import java.util.List;
import org.alfresco.service.cmr.repository.NodeRef; import java.util.Map;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.wcm.AVMUtil;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import freemarker.cache.TemplateLoader;
import freemarker.ext.dom.NodeModel;
import freemarker.template.Configuration;
import freemarker.template.SimpleDate;
import freemarker.template.SimpleHash;
import freemarker.template.SimpleNumber;
import freemarker.template.SimpleScalar;
import freemarker.template.SimpleSequence;
import freemarker.template.Template;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import freemarker.template.TemplateHashModel;
import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
/** /**
* Implementation of a form data renderer for processing xml instance data * Implementation of a form data renderer for processing xml instance data
* using a freemarker template. * using a freemarker template.
@@ -249,6 +264,10 @@ public class FreeMarkerRenderingEngine
{ {
return (Boolean)value ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE; return (Boolean)value ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
} }
else if (value instanceof Date)
{
return new SimpleDate(((Date)value), SimpleDate.DATETIME);
}
else if (value instanceof Document) else if (value instanceof Document)
{ {
return NodeModel.wrap((Document)value); return NodeModel.wrap((Document)value);

View File

@@ -384,7 +384,7 @@ public class RenderingEngineTemplateImpl
model.put(QName.createQName(NamespaceService.ALFRESCO_PREFIX, model.put(QName.createQName(NamespaceService.ALFRESCO_PREFIX,
"date", "date",
namespacePrefixResolver), namespacePrefixResolver),
new SimpleDate(new Date(), SimpleDate.DATETIME)); new Date());
model.put(QName.createQName(NamespaceService.ALFRESCO_PREFIX, model.put(QName.createQName(NamespaceService.ALFRESCO_PREFIX,
"avm_sandbox_url", "avm_sandbox_url",
namespacePrefixResolver), namespacePrefixResolver),