mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
First-cut validation of dynamic model changes
- in case of re-deploy (dynamic update) check for incremental updates only - in case of undeploy (dynamic delete) check for type/aspect usages (in content and workflows) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6698 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
*/
|
||||
package org.alfresco.repo.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||
@@ -70,6 +74,7 @@ import org.alfresco.service.namespace.QName;
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
// note: currently used for model 'diffs'
|
||||
StringBuilder sb = new StringBuilder(56);
|
||||
sb.append("Association")
|
||||
.append("[ class=").append(classDef)
|
||||
@@ -245,5 +250,57 @@ import org.alfresco.service.namespace.QName;
|
||||
{
|
||||
return assoc.isTargetMany();
|
||||
}
|
||||
|
||||
/*package*/ static Collection<M2ModelDiff> diffAssocLists(Collection<AssociationDefinition> previousAssocs, Collection<AssociationDefinition> newAssocs)
|
||||
{
|
||||
List<M2ModelDiff> M2ModelDiffs = new ArrayList<M2ModelDiff>();
|
||||
|
||||
for (AssociationDefinition previousAssoc : previousAssocs)
|
||||
{
|
||||
boolean found = false;
|
||||
for (AssociationDefinition newAssoc : newAssocs)
|
||||
{
|
||||
if (newAssoc.getName().equals(previousAssoc.getName()))
|
||||
{
|
||||
// TODO currently uses toString() to check whether changed - could override equals()
|
||||
if ((((M2AssociationDefinition)previousAssoc).toString()).equals(((M2AssociationDefinition)newAssoc).toString()))
|
||||
{
|
||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UNCHANGED));
|
||||
}
|
||||
else
|
||||
{
|
||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UPDATED));
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! found)
|
||||
{
|
||||
M2ModelDiffs.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)
|
||||
{
|
||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_CREATED));
|
||||
}
|
||||
}
|
||||
|
||||
return M2ModelDiffs;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user