Big honkin' merge from head. Sheesh!

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-27 01:01:30 +00:00
parent e2c66899cc
commit 8031cc6574
322 changed files with 20776 additions and 6550 deletions

View File

@@ -107,7 +107,7 @@ public class DictionaryComponent implements DictionaryService
*/
public Collection<QName> getAllTypes()
{
Collection<QName> types = new ArrayList<QName>();
Collection<QName> types = new ArrayList<QName>(100);
for (QName model : getAllModels())
{
types.addAll(getTypes(model));
@@ -136,7 +136,7 @@ public class DictionaryComponent implements DictionaryService
*/
public Collection<QName> getAllAspects()
{
Collection<QName> aspects = new ArrayList<QName>();
Collection<QName> aspects = new ArrayList<QName>(64);
for (QName model : getAllModels())
{
aspects.addAll(getAspects(model));

View File

@@ -18,7 +18,9 @@ package org.alfresco.repo.dictionary;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
@@ -52,8 +54,8 @@ public class DictionaryDAOImpl implements DictionaryDAO
// Namespace Data Access
private NamespaceDAO namespaceDAO;
// Map of namespace to model name
private Map<String,QName> namespaceToModel = new HashMap<String,QName>();
// Map of Namespace URI usages to Models
private Map<String, List<CompiledModel>> uriToModels = new HashMap<String, List<CompiledModel>>();
// Map of model name to compiled model
private Map<QName,CompiledModel> compiledModels = new HashMap<QName,CompiledModel>();
@@ -90,7 +92,11 @@ public class DictionaryDAOImpl implements DictionaryDAO
{
namespaceDAO.removePrefix(namespace.getPrefix());
namespaceDAO.removeURI(namespace.getUri());
namespaceToModel.remove(namespace.getUri());
unmapUriToModel(namespace.getUri(), previousVersion);
}
for (M2Namespace importNamespace : previousVersion.getM2Model().getImports())
{
unmapUriToModel(importNamespace.getUri(), previousVersion);
}
}
@@ -99,7 +105,11 @@ public class DictionaryDAOImpl implements DictionaryDAO
{
namespaceDAO.addURI(namespace.getUri());
namespaceDAO.addPrefix(namespace.getPrefix(), namespace.getUri());
namespaceToModel.put(namespace.getUri(), modelName);
mapUriToModel(namespace.getUri(), compiledModel);
}
for (M2Namespace importNamespace : model.getImports())
{
mapUriToModel(importNamespace.getUri(), compiledModel);
}
// Publish new Model Definition
@@ -115,6 +125,7 @@ public class DictionaryDAOImpl implements DictionaryDAO
}
}
/**
* @see org.alfresco.repo.dictionary.DictionaryDAO#removeModel(org.alfresco.service.namespace.QName)
*/
@@ -129,7 +140,7 @@ public class DictionaryDAOImpl implements DictionaryDAO
{
namespaceDAO.removePrefix(namespace.getPrefix());
namespaceDAO.removeURI(namespace.getUri());
namespaceToModel.remove(namespace.getUri());
unmapUriToModel(namespace.getUri(), compiledModel);
}
// Remove the model from the list
@@ -137,18 +148,61 @@ public class DictionaryDAOImpl implements DictionaryDAO
}
}
/**
* Map Namespace URI to Model
*
* @param uri namespace uri
* @param model model
*/
private void mapUriToModel(String uri, CompiledModel model)
{
List<CompiledModel> models = uriToModels.get(uri);
if (models == null)
{
models = new ArrayList<CompiledModel>();
uriToModels.put(uri, models);
}
if (!models.contains(model))
{
models.add(model);
}
}
/**
* @param uri the namespace uri
* @return the compiled model which defines the specified namespace
* Unmap Namespace URI from Model
*
* @param uri namespace uri
* @param model model
*/
private CompiledModel getCompiledModelForNamespace(String uri)
private void unmapUriToModel(String uri, CompiledModel model)
{
QName modelName = namespaceToModel.get(uri);
return (modelName == null) ? null : getCompiledModel(modelName);
List<CompiledModel> models = uriToModels.get(uri);
if (models != null)
{
models.remove(model);
}
}
/**
* Get Models mapped to Namespace Uri
*
* @param uri namespace uri
* @return mapped models
*/
private List<CompiledModel> getModelsForUri(String uri)
{
List<CompiledModel> models = uriToModels.get(uri);
if (models == null)
{
models = Collections.emptyList();
}
return models;
}
/**
* @param modelName the model name
* @return the compiled model of the given name
@@ -170,8 +224,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
*/
public DataTypeDefinition getDataType(QName typeName)
{
CompiledModel model = getCompiledModelForNamespace(typeName.getNamespaceURI());
return (model == null) ? null : model.getDataType(typeName);
List<CompiledModel> models = getModelsForUri(typeName.getNamespaceURI());
for (CompiledModel model : models)
{
DataTypeDefinition dataType = model.getDataType(typeName);
if (dataType != null)
{
return dataType;
}
}
return null;
}
@@ -207,8 +269,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
*/
public TypeDefinition getType(QName typeName)
{
CompiledModel model = getCompiledModelForNamespace(typeName.getNamespaceURI());
return (model == null) ? null : model.getType(typeName);
List<CompiledModel> models = getModelsForUri(typeName.getNamespaceURI());
for (CompiledModel model : models)
{
TypeDefinition type = model.getType(typeName);
if (type != null)
{
return type;
}
}
return null;
}
@@ -217,8 +287,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
*/
public AspectDefinition getAspect(QName aspectName)
{
CompiledModel model = getCompiledModelForNamespace(aspectName.getNamespaceURI());
return (model == null) ? null : model.getAspect(aspectName);
List<CompiledModel> models = getModelsForUri(aspectName.getNamespaceURI());
for (CompiledModel model : models)
{
AspectDefinition aspect = model.getAspect(aspectName);
if (aspect != null)
{
return aspect;
}
}
return null;
}
@@ -227,8 +305,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
*/
public ClassDefinition getClass(QName className)
{
CompiledModel model = getCompiledModelForNamespace(className.getNamespaceURI());
return (model == null) ? null : model.getClass(className);
List<CompiledModel> models = getModelsForUri(className.getNamespaceURI());
for (CompiledModel model : models)
{
ClassDefinition classDef = model.getClass(className);
if (classDef != null)
{
return classDef;
}
}
return null;
}
@@ -237,23 +323,52 @@ public class DictionaryDAOImpl implements DictionaryDAO
*/
public PropertyDefinition getProperty(QName propertyName)
{
CompiledModel model = getCompiledModelForNamespace(propertyName.getNamespaceURI());
return (model == null) ? null : model.getProperty(propertyName);
List<CompiledModel> models = getModelsForUri(propertyName.getNamespaceURI());
for (CompiledModel model : models)
{
PropertyDefinition propDef = model.getProperty(propertyName);
if (propDef != null)
{
return propDef;
}
}
return null;
}
/* (non-Javadoc)
* @see org.alfresco.repo.dictionary.ModelQuery#getConstraint(org.alfresco.service.namespace.QName)
*/
public ConstraintDefinition getConstraint(QName constraintQName)
{
CompiledModel model = getCompiledModelForNamespace(constraintQName.getNamespaceURI());
return (model == null) ? null : model.getConstraint(constraintQName);
List<CompiledModel> models = getModelsForUri(constraintQName.getNamespaceURI());
for (CompiledModel model : models)
{
ConstraintDefinition constraintDef = model.getConstraint(constraintQName);
if (constraintDef != null)
{
return constraintDef;
}
}
return null;
}
/* (non-Javadoc)
* @see org.alfresco.repo.dictionary.impl.ModelQuery#getAssociation(org.alfresco.repo.ref.QName)
*/
public AssociationDefinition getAssociation(QName assocName)
{
CompiledModel model = getCompiledModelForNamespace(assocName.getNamespaceURI());
return (model == null) ? null : model.getAssociation(assocName);
List<CompiledModel> models = getModelsForUri(assocName.getNamespaceURI());
for (CompiledModel model : models)
{
AssociationDefinition assocDef = model.getAssociation(assocName);
if (assocDef != null)
{
return assocDef;
}
}
return null;
}

View File

@@ -186,6 +186,15 @@ public class DictionaryDAOTest extends TestCase
ClassDefinition fileClassDef = service.getClass(testFileQName);
assertTrue("File type should have the archive flag", fileClassDef.isArchive());
QName testFileDerivedQName = QName.createQName(TEST_URL, "file-derived");
ClassDefinition fileDerivedClassDef = service.getClass(testFileDerivedQName);
assertTrue("Direct derived File type should have the archive flag", fileDerivedClassDef.isArchive());
QName testFileDerivedNoArchiveQName = QName.createQName(TEST_URL, "file-derived-no-archive");
ClassDefinition fileDerivedNoArchiveClassDef = service.getClass(testFileDerivedNoArchiveQName);
assertFalse("Derived File with archive override type should NOT have the archive flag",
fileDerivedNoArchiveClassDef.isArchive());
QName testFolderQName = QName.createQName(TEST_URL, "folder");
ClassDefinition folderClassDef = service.getClass(testFolderQName);
assertFalse("Folder type should not have the archive flag", folderClassDef.isArchive());

View File

@@ -32,7 +32,7 @@ public abstract class M2Class
private String title = null;
private String description = null;
private String parentName = null;
private boolean archive = false;
private Boolean archive = null;
private List<M2Property> properties = new ArrayList<M2Property>();
private List<M2PropertyOverride> propertyOverrides = new ArrayList<M2PropertyOverride>();
@@ -92,14 +92,14 @@ public abstract class M2Class
}
public boolean isArchive()
public Boolean getArchive()
{
return archive;
}
public void setArchive(boolean archive)
{
this.archive = archive;
this.archive = Boolean.valueOf(archive);
}
public M2Property createProperty(String name)

View File

@@ -46,7 +46,6 @@ import org.alfresco.service.namespace.QName;
protected M2Class m2Class;
protected QName name;
protected QName parentName = null;
protected boolean archive = false;
private Map<QName, M2PropertyOverride> propertyOverrides = new HashMap<QName, M2PropertyOverride>();
private Map<QName, PropertyDefinition> properties = new HashMap<QName, PropertyDefinition>();
@@ -57,8 +56,9 @@ import org.alfresco.service.namespace.QName;
private List<AspectDefinition> defaultAspects = new ArrayList<AspectDefinition>();
private List<QName> defaultAspectNames = new ArrayList<QName>();
private List<AspectDefinition> inheritedDefaultAspects = new ArrayList<AspectDefinition>();
private Boolean archive = null;
private Boolean inheritedArchive = null;
/**
* Construct
*
@@ -74,7 +74,7 @@ import org.alfresco.service.namespace.QName;
// Resolve Names
this.name = QName.createQName(m2Class.getName(), resolver);
this.archive = m2Class.isArchive();
this.archive = m2Class.getArchive();
if (m2Class.getParentName() != null && m2Class.getParentName().length() > 0)
{
this.parentName = QName.createQName(m2Class.getParentName(), resolver);
@@ -162,8 +162,8 @@ import org.alfresco.service.namespace.QName;
public String toString()
{
StringBuilder sb = new StringBuilder(120);
sb.append("ClassDef ")
.append("[ name=").append(name)
sb.append("ClassDef")
.append("[name=").append(name)
.append("]");
return sb.toString();
}
@@ -191,6 +191,15 @@ import org.alfresco.service.namespace.QName;
{
((M2AssociationDefinition)def).resolveDependencies(query);
}
for (Map.Entry<QName, M2PropertyOverride> override : propertyOverrides.entrySet())
{
PropertyDefinition propDef = query.getProperty(override.getKey());
if (propDef == null)
{
throw new DictionaryException("Class " + name.toPrefixString() + " attempting to override property " + override.getKey().toPrefixString() + " which does not exist");
}
}
for (QName aspectName : defaultAspectNames)
{
@@ -280,6 +289,13 @@ import org.alfresco.service.namespace.QName;
inheritedDefaultAspects.add(def);
}
}
// resolve archive inheritance
if (parentClass != null && archive == null)
{
// archive not explicitly set on this class and there is a parent class
inheritedArchive = ((M2ClassDefinition)parentClass).isArchive();
}
}
/* (non-Javadoc)
@@ -340,8 +356,23 @@ import org.alfresco.service.namespace.QName;
return (m2Class instanceof M2Aspect);
}
/**
* @return Returns the archive flag, which defaults to <tt>false</tt>
*/
public boolean isArchive()
{
if (archive == null)
{
if (inheritedArchive != null)
{
return inheritedArchive.booleanValue();
}
else
{
// default to false
return false;
}
}
return archive;
}

View File

@@ -150,6 +150,15 @@
</overrides>
</type>
<type name="test:file-derived">
<parent>test:file</parent>
</type>
<type name="test:file-derived-no-archive">
<parent>test:file</parent>
<archive>false</archive>
</type>
<type name="test:folder">
<parent>test:base</parent>
<properties>