mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM - custom/dynamic model support for incremental updates to title/description
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16152 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1111,6 +1111,18 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
/**
|
/**
|
||||||
* Return diffs between two compiled models.
|
* Return diffs between two compiled models.
|
||||||
*
|
*
|
||||||
|
* note:
|
||||||
|
* - checks classes (types & aspects) for incremental updates
|
||||||
|
* - checks properties for incremental updates, but does not include the diffs
|
||||||
|
* - checks assocs & child assocs for incremental updates, but does not include the diffs
|
||||||
|
* - incremental updates include changes in title/description, property default value, etc
|
||||||
|
* - ignores changes in model definition except name (ie. title, description, author, published date, version are treated as an incremental update)
|
||||||
|
*
|
||||||
|
* TODO
|
||||||
|
* - imports
|
||||||
|
* - namespace
|
||||||
|
* - datatypes
|
||||||
|
* - constraints (including property constraints - references and inline)
|
||||||
*
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return model diffs (if any)
|
* @return model diffs (if any)
|
||||||
|
@@ -754,6 +754,106 @@ public class DiffModelTest extends TestCase
|
|||||||
|
|
||||||
"</model>";
|
"</model>";
|
||||||
|
|
||||||
|
public static final String MODEL6_XML =
|
||||||
|
"<model name=\"test1:model6\" xmlns=\"http://www.alfresco.org/model/dictionary/1.0\">" +
|
||||||
|
|
||||||
|
" <description>Another description</description>" +
|
||||||
|
" <author>Alfresco</author>" +
|
||||||
|
" <published>2007-08-01</published>" +
|
||||||
|
" <version>1.0</version>" +
|
||||||
|
|
||||||
|
" <imports>" +
|
||||||
|
" <import uri=\"http://www.alfresco.org/model/dictionary/1.0\" prefix=\"d\"/>" +
|
||||||
|
" </imports>" +
|
||||||
|
|
||||||
|
" <namespaces>" +
|
||||||
|
" <namespace uri=\"http://www.alfresco.org/model/test1/1.0\" prefix=\"test1\"/>" +
|
||||||
|
" </namespaces>" +
|
||||||
|
|
||||||
|
" <types>" +
|
||||||
|
|
||||||
|
" <type name=\"test1:type1\">" +
|
||||||
|
" <title>Type1 Title</title>" +
|
||||||
|
" <description>Type1 Description</description>" +
|
||||||
|
" <properties>" +
|
||||||
|
" <property name=\"test1:prop1\">" +
|
||||||
|
" <title>Prop1 Title</title>" +
|
||||||
|
" <description>Prop1 Description</description>" +
|
||||||
|
" <type>d:text</type>" +
|
||||||
|
" </property>" +
|
||||||
|
" </properties>" +
|
||||||
|
" </type>" +
|
||||||
|
|
||||||
|
" </types>" +
|
||||||
|
|
||||||
|
" <aspects>" +
|
||||||
|
|
||||||
|
" <aspect name=\"test1:aspect1\">" +
|
||||||
|
" <title>Aspect1 Title</title>" +
|
||||||
|
" <description>Aspect1 Description</description>" +
|
||||||
|
" <properties>" +
|
||||||
|
" <property name=\"test1:prop9\">" +
|
||||||
|
" <title>Prop9 Title</title>" +
|
||||||
|
" <description>Prop9 Description</description>" +
|
||||||
|
" <type>d:text</type>" +
|
||||||
|
" </property>" +
|
||||||
|
" </properties>" +
|
||||||
|
" </aspect>" +
|
||||||
|
|
||||||
|
" </aspects>" +
|
||||||
|
|
||||||
|
"</model>";
|
||||||
|
|
||||||
|
public static final String MODEL6_UPDATE1_XML =
|
||||||
|
"<model name=\"test1:model6\" xmlns=\"http://www.alfresco.org/model/dictionary/1.0\">" +
|
||||||
|
|
||||||
|
" <description>Another description - UPDATE1</description>" +
|
||||||
|
" <author>Alfresco - UPDATE1</author>" +
|
||||||
|
" <published>2009-08-01</published>" +
|
||||||
|
" <version>2.0</version>" +
|
||||||
|
|
||||||
|
" <imports>" +
|
||||||
|
" <import uri=\"http://www.alfresco.org/model/dictionary/1.0\" prefix=\"d\"/>" +
|
||||||
|
" </imports>" +
|
||||||
|
|
||||||
|
" <namespaces>" +
|
||||||
|
" <namespace uri=\"http://www.alfresco.org/model/test1/1.0\" prefix=\"test1\"/>" +
|
||||||
|
" </namespaces>" +
|
||||||
|
|
||||||
|
" <types>" +
|
||||||
|
|
||||||
|
" <type name=\"test1:type1\">" +
|
||||||
|
" <title>Type1 Title - UPDATE1</title>" +
|
||||||
|
" <description>Type1 Description - UPDATE1</description>" +
|
||||||
|
" <properties>" +
|
||||||
|
" <property name=\"test1:prop1\">" +
|
||||||
|
" <title>Prop1 Title - UPDATE1</title>" +
|
||||||
|
" <description>Prop1 Description - UPDATE1</description>" +
|
||||||
|
" <type>d:text</type>" +
|
||||||
|
" </property>" +
|
||||||
|
" </properties>" +
|
||||||
|
" </type>" +
|
||||||
|
|
||||||
|
" </types>" +
|
||||||
|
|
||||||
|
" <aspects>" +
|
||||||
|
|
||||||
|
" <aspect name=\"test1:aspect1\">" +
|
||||||
|
" <title>Aspect1 Title</title>" +
|
||||||
|
" <description>Aspect1 Description</description>" +
|
||||||
|
" <properties>" +
|
||||||
|
" <property name=\"test1:prop9\">" +
|
||||||
|
" <title>Prop9 Title - UPDATE1</title>" +
|
||||||
|
" <description>Prop9 Description - UPDATE1</description>" +
|
||||||
|
" <type>d:text</type>" +
|
||||||
|
" </property>" +
|
||||||
|
" </properties>" +
|
||||||
|
" </aspect>" +
|
||||||
|
|
||||||
|
" </aspects>" +
|
||||||
|
|
||||||
|
"</model>";
|
||||||
|
|
||||||
private DictionaryDAOImpl dictionaryDAO;
|
private DictionaryDAOImpl dictionaryDAO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -998,6 +1098,31 @@ public class DiffModelTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIncUpdateTitleDescription()
|
||||||
|
{
|
||||||
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(MODEL6_XML.getBytes());
|
||||||
|
M2Model model = M2Model.createModel(byteArrayInputStream);
|
||||||
|
QName modelName = dictionaryDAO.putModel(model);
|
||||||
|
CompiledModel previousVersion = dictionaryDAO.getCompiledModel(modelName);
|
||||||
|
|
||||||
|
byteArrayInputStream = new ByteArrayInputStream(MODEL6_UPDATE1_XML.getBytes());
|
||||||
|
model = M2Model.createModel(byteArrayInputStream);
|
||||||
|
modelName = dictionaryDAO.putModel(model);
|
||||||
|
CompiledModel newVersion = dictionaryDAO.getCompiledModel(modelName);
|
||||||
|
|
||||||
|
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||||
|
|
||||||
|
for (M2ModelDiff modelDiff : modelDiffs)
|
||||||
|
{
|
||||||
|
System.out.println(modelDiff.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(2, modelDiffs.size());
|
||||||
|
|
||||||
|
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UPDATED_INC));
|
||||||
|
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UPDATED_INC));
|
||||||
|
}
|
||||||
|
|
||||||
public void testNonIncUpdatePropertiesRemoved()
|
public void testNonIncUpdatePropertiesRemoved()
|
||||||
{
|
{
|
||||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(MODEL2_EXTRA_PROPERTIES_XML.getBytes());
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(MODEL2_EXTRA_PROPERTIES_XML.getBytes());
|
||||||
|
@@ -1,306 +1,370 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
* As a special exception to the terms and conditions of version 2.0 of
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
* FLOSS exception. You should have recieved a copy of the text describing
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
* the FLOSS exception, and it is also available here:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing"
|
* http://www.alfresco.com/legal/licensing"
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.dictionary;
|
package org.alfresco.repo.dictionary;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||||
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
||||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
|
||||||
/**
|
|
||||||
* Compiled Association Definition.
|
/**
|
||||||
*
|
* Compiled Association Definition.
|
||||||
* @author David Caruana
|
*
|
||||||
*/
|
* @author David Caruana
|
||||||
/*package*/ class M2AssociationDefinition implements AssociationDefinition
|
*/
|
||||||
{
|
/*package*/ class M2AssociationDefinition implements AssociationDefinition
|
||||||
|
{
|
||||||
private ClassDefinition classDef;
|
|
||||||
private M2ClassAssociation assoc;
|
private ClassDefinition classDef;
|
||||||
private QName name;
|
private M2ClassAssociation assoc;
|
||||||
private QName targetClassName;
|
private QName name;
|
||||||
private ClassDefinition targetClass;
|
private QName targetClassName;
|
||||||
private QName sourceRoleName;
|
private ClassDefinition targetClass;
|
||||||
private QName targetRoleName;
|
private QName sourceRoleName;
|
||||||
|
private QName targetRoleName;
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct
|
/**
|
||||||
*
|
* Construct
|
||||||
* @param m2Association association definition
|
*
|
||||||
* @return the definition
|
* @param m2Association association definition
|
||||||
*/
|
* @return the definition
|
||||||
/*package*/ M2AssociationDefinition(ClassDefinition classDef, M2ClassAssociation assoc, NamespacePrefixResolver resolver)
|
*/
|
||||||
{
|
/*package*/ M2AssociationDefinition(ClassDefinition classDef, M2ClassAssociation assoc, NamespacePrefixResolver resolver)
|
||||||
this.classDef = classDef;
|
{
|
||||||
this.assoc = assoc;
|
this.classDef = classDef;
|
||||||
|
this.assoc = assoc;
|
||||||
// Resolve names
|
|
||||||
this.name = QName.createQName(assoc.getName(), resolver);
|
// Resolve names
|
||||||
this.targetClassName = QName.createQName(assoc.getTargetClassName(), resolver);
|
this.name = QName.createQName(assoc.getName(), resolver);
|
||||||
this.sourceRoleName = QName.createQName(assoc.getSourceRoleName(), resolver);
|
this.targetClassName = QName.createQName(assoc.getTargetClassName(), resolver);
|
||||||
this.targetRoleName = QName.createQName(assoc.getTargetRoleName(), resolver);
|
this.sourceRoleName = QName.createQName(assoc.getSourceRoleName(), resolver);
|
||||||
}
|
this.targetRoleName = QName.createQName(assoc.getTargetRoleName(), resolver);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String toString()
|
@Override
|
||||||
{
|
public String toString()
|
||||||
// note: currently used for model 'diffs'
|
{
|
||||||
StringBuilder sb = new StringBuilder(56);
|
StringBuilder sb = new StringBuilder(56);
|
||||||
sb.append("Association")
|
sb.append("Association")
|
||||||
.append("[ class=").append(classDef)
|
.append("[ class=").append(classDef)
|
||||||
.append(", name=").append(name)
|
.append(", name=").append(name)
|
||||||
.append(", target class=").append(targetClassName)
|
.append(", target class=").append(targetClassName)
|
||||||
.append(", source role=").append(sourceRoleName)
|
.append(", source role=").append(sourceRoleName)
|
||||||
.append(", target role=").append(targetRoleName)
|
.append(", target role=").append(targetRoleName)
|
||||||
.append("]");
|
.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*package*/ M2ClassAssociation getM2Association()
|
/*package*/ M2ClassAssociation getM2Association()
|
||||||
{
|
{
|
||||||
return assoc;
|
return assoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*package*/ void resolveDependencies(ModelQuery query)
|
/*package*/ void resolveDependencies(ModelQuery query)
|
||||||
{
|
{
|
||||||
if (targetClassName == null)
|
if (targetClassName == null)
|
||||||
{
|
{
|
||||||
throw new DictionaryException("Target class of association " + name.toPrefixString() + " must be specified");
|
throw new DictionaryException("Target class of association " + name.toPrefixString() + " must be specified");
|
||||||
}
|
}
|
||||||
targetClass = query.getClass(targetClassName);
|
targetClass = query.getClass(targetClassName);
|
||||||
if (targetClass == null)
|
if (targetClass == null)
|
||||||
{
|
{
|
||||||
throw new DictionaryException("Target class " + targetClassName.toPrefixString() + " of association " + name.toPrefixString() + " is not found");
|
throw new DictionaryException("Target class " + targetClassName.toPrefixString() + " of association " + name.toPrefixString() + " is not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.dictionary.AssociationDefinition#getModel()
|
* @see org.alfresco.service.cmr.dictionary.AssociationDefinition#getModel()
|
||||||
*/
|
*/
|
||||||
public ModelDefinition getModel()
|
public ModelDefinition getModel()
|
||||||
{
|
{
|
||||||
return classDef.getModel();
|
return classDef.getModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getName()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getName()
|
||||||
*/
|
*/
|
||||||
public QName getName()
|
public QName getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isChild()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isChild()
|
||||||
*/
|
*/
|
||||||
public boolean isChild()
|
public boolean isChild()
|
||||||
{
|
{
|
||||||
return (assoc instanceof M2ChildAssociation);
|
return (assoc instanceof M2ChildAssociation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getTitle()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getTitle()
|
||||||
*/
|
*/
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
String value = M2Label.getLabel(classDef.getModel(), "association", name, "title");
|
String value = M2Label.getLabel(classDef.getModel(), "association", name, "title");
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
value = assoc.getTitle();
|
value = assoc.getTitle();
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getDescription()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getDescription()
|
||||||
*/
|
*/
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
String value = M2Label.getLabel(classDef.getModel(), "association", name, "description");
|
String value = M2Label.getLabel(classDef.getModel(), "association", name, "description");
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
value = assoc.getDescription();
|
value = assoc.getDescription();
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isProtected()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isProtected()
|
||||||
*/
|
*/
|
||||||
public boolean isProtected()
|
public boolean isProtected()
|
||||||
{
|
{
|
||||||
return assoc.isProtected();
|
return assoc.isProtected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getSourceClass()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getSourceClass()
|
||||||
*/
|
*/
|
||||||
public ClassDefinition getSourceClass()
|
public ClassDefinition getSourceClass()
|
||||||
{
|
{
|
||||||
return classDef;
|
return classDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getSourceRoleName()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getSourceRoleName()
|
||||||
*/
|
*/
|
||||||
public QName getSourceRoleName()
|
public QName getSourceRoleName()
|
||||||
{
|
{
|
||||||
return sourceRoleName;
|
return sourceRoleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isSourceMandatory()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isSourceMandatory()
|
||||||
*/
|
*/
|
||||||
public boolean isSourceMandatory()
|
public boolean isSourceMandatory()
|
||||||
{
|
{
|
||||||
return assoc.isSourceMandatory();
|
return assoc.isSourceMandatory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isSourceMany()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isSourceMany()
|
||||||
*/
|
*/
|
||||||
public boolean isSourceMany()
|
public boolean isSourceMany()
|
||||||
{
|
{
|
||||||
return assoc.isSourceMany();
|
return assoc.isSourceMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getTargetClass()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getTargetClass()
|
||||||
*/
|
*/
|
||||||
public ClassDefinition getTargetClass()
|
public ClassDefinition getTargetClass()
|
||||||
{
|
{
|
||||||
return targetClass;
|
return targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#getTargetRoleName()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#getTargetRoleName()
|
||||||
*/
|
*/
|
||||||
public QName getTargetRoleName()
|
public QName getTargetRoleName()
|
||||||
{
|
{
|
||||||
return targetRoleName;
|
return targetRoleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isTargetMandatory()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isTargetMandatory()
|
||||||
*/
|
*/
|
||||||
public boolean isTargetMandatory()
|
public boolean isTargetMandatory()
|
||||||
{
|
{
|
||||||
return assoc.isTargetMandatory();
|
return assoc.isTargetMandatory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMandatoryEnforced()
|
* @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMandatoryEnforced()
|
||||||
*/
|
*/
|
||||||
public boolean isTargetMandatoryEnforced()
|
public boolean isTargetMandatoryEnforced()
|
||||||
{
|
{
|
||||||
return assoc.isTargetMandatoryEnforced();
|
return assoc.isTargetMandatoryEnforced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isTargetMany()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isTargetMany()
|
||||||
*/
|
*/
|
||||||
public boolean isTargetMany()
|
public boolean isTargetMany()
|
||||||
{
|
{
|
||||||
return assoc.isTargetMany();
|
return assoc.isTargetMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ static Collection<M2ModelDiff> diffAssocLists(Collection<AssociationDefinition> previousAssocs, Collection<AssociationDefinition> newAssocs)
|
/* package */ M2ModelDiff diffAssoc(AssociationDefinition assocDef)
|
||||||
{
|
{
|
||||||
List<M2ModelDiff> M2ModelDiffs = new ArrayList<M2ModelDiff>();
|
M2ModelDiff modelDiff = null;
|
||||||
|
boolean isUpdated = false;
|
||||||
for (AssociationDefinition previousAssoc : previousAssocs)
|
boolean isUpdatedIncrementally = false;
|
||||||
{
|
|
||||||
boolean found = false;
|
if (this == assocDef)
|
||||||
for (AssociationDefinition newAssoc : newAssocs)
|
{
|
||||||
{
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UNCHANGED);
|
||||||
if (newAssoc.getName().equals(previousAssoc.getName()))
|
return modelDiff;
|
||||||
{
|
}
|
||||||
// TODO currently uses toString() to check whether changed - could override equals()
|
|
||||||
if ((((M2AssociationDefinition)previousAssoc).toString()).equals(((M2AssociationDefinition)newAssoc).toString()))
|
// check name - cannot be null
|
||||||
{
|
if (! name.equals(assocDef.getName()))
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UNCHANGED));
|
{
|
||||||
}
|
isUpdated = true;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UPDATED));
|
// check title
|
||||||
}
|
if (! EqualsHelper.nullSafeEquals(getTitle(), assocDef.getTitle(), false))
|
||||||
found = true;
|
{
|
||||||
break;
|
isUpdatedIncrementally = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// check description
|
||||||
if (! found)
|
if (! EqualsHelper.nullSafeEquals(getDescription(), assocDef.getDescription(), false))
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(previousAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_DELETED));
|
isUpdatedIncrementally = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// check source class qname
|
||||||
for (AssociationDefinition newAssoc : newAssocs)
|
if (! EqualsHelper.nullSafeEquals(getSourceClass().getName(), assocDef.getSourceClass().getName()))
|
||||||
{
|
{
|
||||||
boolean found = false;
|
isUpdated = true;
|
||||||
for (AssociationDefinition previousAssoc : previousAssocs)
|
}
|
||||||
{
|
|
||||||
if (newAssoc.getName().equals(previousAssoc.getName()))
|
// check source role qname
|
||||||
{
|
if (! EqualsHelper.nullSafeEquals(getSourceRoleName(), assocDef.getSourceRoleName()))
|
||||||
found = true;
|
{
|
||||||
break;
|
isUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// check target class qname
|
||||||
if (! found)
|
if (! EqualsHelper.nullSafeEquals(getTargetClass().getName(), assocDef.getTargetClass().getName()))
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_CREATED));
|
isUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// check target role qname
|
||||||
return M2ModelDiffs;
|
if (! EqualsHelper.nullSafeEquals(getTargetRoleName(), assocDef.getTargetRoleName()))
|
||||||
}
|
{
|
||||||
|
isUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO - additional checks - is... (x7)
|
||||||
|
|
||||||
|
if (isUpdated)
|
||||||
|
{
|
||||||
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UPDATED);
|
||||||
|
}
|
||||||
|
else if (isUpdatedIncrementally)
|
||||||
|
{
|
||||||
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UPDATED_INC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UNCHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return modelDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ static Collection<M2ModelDiff> diffAssocLists(Collection<AssociationDefinition> previousAssocs, Collection<AssociationDefinition> newAssocs)
|
||||||
|
{
|
||||||
|
List<M2ModelDiff> modelDiffs = new ArrayList<M2ModelDiff>();
|
||||||
|
|
||||||
|
for (AssociationDefinition previousAssoc : previousAssocs)
|
||||||
|
{
|
||||||
|
boolean found = false;
|
||||||
|
for (AssociationDefinition newAssoc : newAssocs)
|
||||||
|
{
|
||||||
|
if (newAssoc.getName().equals(previousAssoc.getName()))
|
||||||
|
{
|
||||||
|
modelDiffs.add(((M2AssociationDefinition)previousAssoc).diffAssoc(newAssoc));
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! found)
|
||||||
|
{
|
||||||
|
modelDiffs.add(new M2ModelDiff(previousAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_DELETED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AssociationDefinition newAssoc : newAssocs)
|
||||||
|
{
|
||||||
|
boolean found = false;
|
||||||
|
for (AssociationDefinition previousAssoc : previousAssocs)
|
||||||
|
{
|
||||||
|
if (newAssoc.getName().equals(previousAssoc.getName()))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! found)
|
||||||
|
{
|
||||||
|
modelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_CREATED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return modelDiffs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -44,6 +44,7 @@ import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
|||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,11 +479,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* return differences in class definition
|
* return differences in class definition
|
||||||
*
|
*
|
||||||
* note:
|
* note:
|
||||||
* - ignores changes in model title, description, author, published date, version
|
|
||||||
* - ignores changes in default values
|
|
||||||
* - checks properties for incremental updates, but does not include the diffs
|
* - checks properties for incremental updates, but does not include the diffs
|
||||||
* - checks assocs & child assocs for incremental updates, but does not include the diffs
|
* - checks assocs & child assocs for incremental updates, but does not include the diffs
|
||||||
* - does not check default values
|
* - incremental updates include changes in title/description, property default value, etc
|
||||||
*/
|
*/
|
||||||
/* package */ List<M2ModelDiff> diffClass(ClassDefinition classDef)
|
/* package */ List<M2ModelDiff> diffClass(ClassDefinition classDef)
|
||||||
{
|
{
|
||||||
@@ -497,6 +496,18 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
// check name - cannot be null
|
// check name - cannot be null
|
||||||
if (! name.equals(classDef.getName()))
|
if (! name.equals(classDef.getName()))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check title
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getTitle(), classDef.getTitle(), false))
|
||||||
|
{
|
||||||
|
isUpdatedIncrementally = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check description
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getDescription(), classDef.getDescription(), false))
|
||||||
{
|
{
|
||||||
isUpdatedIncrementally = true;
|
isUpdatedIncrementally = true;
|
||||||
}
|
}
|
||||||
@@ -682,7 +693,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
modelDiffs.add(new M2ModelDiff(newClass.getName(), M2ModelDiffType, M2ModelDiff.DIFF_CREATED));
|
modelDiffs.add(new M2ModelDiff(newClass.getName(), M2ModelDiffType, M2ModelDiff.DIFF_CREATED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return modelDiffs;
|
return modelDiffs;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user