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,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
@@ -34,6 +34,7 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +75,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
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)
|
||||||
@@ -251,26 +251,90 @@ import org.alfresco.service.namespace.QName;
|
|||||||
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;
|
||||||
|
boolean isUpdatedIncrementally = false;
|
||||||
|
|
||||||
for (AssociationDefinition previousAssoc : previousAssocs)
|
if (this == assocDef)
|
||||||
{
|
{
|
||||||
boolean found = false;
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UNCHANGED);
|
||||||
for (AssociationDefinition newAssoc : newAssocs)
|
return modelDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check name - cannot be null
|
||||||
|
if (! name.equals(assocDef.getName()))
|
||||||
{
|
{
|
||||||
if (newAssoc.getName().equals(previousAssoc.getName()))
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check title
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getTitle(), assocDef.getTitle(), false))
|
||||||
{
|
{
|
||||||
// TODO currently uses toString() to check whether changed - could override equals()
|
isUpdatedIncrementally = true;
|
||||||
if ((((M2AssociationDefinition)previousAssoc).toString()).equals(((M2AssociationDefinition)newAssoc).toString()))
|
}
|
||||||
|
|
||||||
|
// check description
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getDescription(), assocDef.getDescription(), false))
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UNCHANGED));
|
isUpdatedIncrementally = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check source class qname
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getSourceClass().getName(), assocDef.getSourceClass().getName()))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check source role qname
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getSourceRoleName(), assocDef.getSourceRoleName()))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check target class qname
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getTargetClass().getName(), assocDef.getTargetClass().getName()))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check target role qname
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_UPDATED));
|
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;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -278,7 +342,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(previousAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_DELETED));
|
modelDiffs.add(new M2ModelDiff(previousAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_DELETED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,11 +360,11 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_CREATED));
|
modelDiffs.add(new M2ModelDiff(newAssoc.getName(), M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_CREATED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return M2ModelDiffs;
|
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;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
@@ -39,6 +39,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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,7 +227,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
// note: currently used for model 'diffs'
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("Name: " + getName() + "\n");
|
sb.append("Name: " + getName() + "\n");
|
||||||
sb.append("Title: " + getTitle() + "\n");
|
sb.append("Title: " + getTitle() + "\n");
|
||||||
@@ -401,26 +401,138 @@ import org.alfresco.service.namespace.QName;
|
|||||||
return constraintDefs;
|
return constraintDefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ static Collection<M2ModelDiff> diffPropertyLists(Collection<PropertyDefinition> previousProperties, Collection<PropertyDefinition> newProperties)
|
/* package */ M2ModelDiff diffProperty(PropertyDefinition propDef)
|
||||||
{
|
{
|
||||||
List<M2ModelDiff> M2ModelDiffs = new ArrayList<M2ModelDiff>();
|
M2ModelDiff modelDiff = null;
|
||||||
|
boolean isUpdated = false;
|
||||||
|
boolean isUpdatedIncrementally = false;
|
||||||
|
|
||||||
for (PropertyDefinition previousProperty : previousProperties)
|
if (this == propDef)
|
||||||
{
|
{
|
||||||
boolean found = false;
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED);
|
||||||
for (PropertyDefinition newProperty : newProperties)
|
return modelDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check name - cannot be null
|
||||||
|
if (! name.equals(propDef.getName()))
|
||||||
{
|
{
|
||||||
if (newProperty.getName().equals(previousProperty.getName()))
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check title
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getTitle(), propDef.getTitle(), false))
|
||||||
{
|
{
|
||||||
// TODO currently uses toString() to check whether changed - could override equals()
|
isUpdatedIncrementally = true;
|
||||||
if ((((M2PropertyDefinition)previousProperty).toString()).equals(((M2PropertyDefinition)newProperty).toString()))
|
}
|
||||||
|
|
||||||
|
// check description
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getDescription(), propDef.getDescription(), false))
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newProperty.getName(), M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
isUpdatedIncrementally = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check default value
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getDefaultValue(), propDef.getDefaultValue(), false))
|
||||||
|
{
|
||||||
|
isUpdatedIncrementally = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check datatype qname (TODO check datatype defs separately)
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getDataType().getName(), propDef.getDataType().getName()))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check container class qname
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getContainerClass().getName(), propDef.getContainerClass().getName()))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check multi-valued
|
||||||
|
if (isMultiValued() != propDef.isMultiValued())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check mandatory
|
||||||
|
if (isMandatory() != propDef.isMandatory())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check mandatory enforced
|
||||||
|
if (isMandatoryEnforced() != propDef.isMandatoryEnforced())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check protected
|
||||||
|
if (isProtected() != propDef.isProtected())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check indexed
|
||||||
|
if (isIndexed() != propDef.isIndexed())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check stored in index
|
||||||
|
if (isStoredInIndex() != propDef.isStoredInIndex())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check auto index
|
||||||
|
if (isIndexedAtomically() != propDef.isIndexedAtomically())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check override
|
||||||
|
if (isOverride() != propDef.isOverride())
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check index tokenisation mode
|
||||||
|
if (! EqualsHelper.nullSafeEquals(getIndexTokenisationMode().toString(), propDef.getIndexTokenisationMode().toString(), false))
|
||||||
|
{
|
||||||
|
isUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - check prop constraints (inline and referenced)
|
||||||
|
|
||||||
|
if (isUpdated)
|
||||||
|
{
|
||||||
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UPDATED);
|
||||||
|
}
|
||||||
|
else if (isUpdatedIncrementally)
|
||||||
|
{
|
||||||
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UPDATED_INC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newProperty.getName(), M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UPDATED));
|
modelDiff = new M2ModelDiff(name, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return modelDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ static Collection<M2ModelDiff> diffPropertyLists(Collection<PropertyDefinition> previousProperties, Collection<PropertyDefinition> newProperties)
|
||||||
|
{
|
||||||
|
List<M2ModelDiff> modelDiffs = new ArrayList<M2ModelDiff>();
|
||||||
|
|
||||||
|
for (PropertyDefinition previousProperty : previousProperties)
|
||||||
|
{
|
||||||
|
boolean found = false;
|
||||||
|
for (PropertyDefinition newProperty : newProperties)
|
||||||
|
{
|
||||||
|
if (newProperty.getName().equals(previousProperty.getName()))
|
||||||
|
{
|
||||||
|
modelDiffs.add(((M2PropertyDefinition)previousProperty).diffProperty(newProperty));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -428,7 +540,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(previousProperty.getName(), M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_DELETED));
|
modelDiffs.add(new M2ModelDiff(previousProperty.getName(), M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_DELETED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,10 +558,10 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
M2ModelDiffs.add(new M2ModelDiff(newProperty.getName(), M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_CREATED));
|
modelDiffs.add(new M2ModelDiff(newProperty.getName(), M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_CREATED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return M2ModelDiffs;
|
return modelDiffs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user