Dictionary support for d:locale data type

System aspect sys:localized
Interface definition of MultilingualContentService


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4607 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-12-14 14:40:10 +00:00
parent e70798e59f
commit ab252efe82
9 changed files with 154 additions and 14 deletions

View File

@@ -230,11 +230,11 @@
<associations>
<child-association name="cm:mlChild">
<source>
<mandatory>true</mandatory>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:mlTranslation</class>
<class>sys:localized</class>
<mandatory>true</mandatory>
<many>true</many>
</target>
@@ -694,18 +694,6 @@
</properties>
</aspect>
<!-- Multilingual -->
<aspect name="cm:mlTranslation">
<title>Translation</title>
<properties>
<property name="cm:language">
<title>Language</title>
<type>d:mltext</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
</aspects>
</model>

View File

@@ -103,6 +103,11 @@
<java-class>org.alfresco.service.cmr.repository.NodeRef</java-class>
</data-type>
<data-type name="d:locale">
<analyser-class>org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser</analyser-class>
<java-class>java.util.Locale</java-class>
</data-type>
</data-types>

View File

@@ -186,6 +186,22 @@
</properties>
</aspect>
<!--
Localization:
If you add this aspect to a node, then the server will assume that all non-multilingual
properties apply to this locale.
-->
<aspect name="sys:localized">
<title>Translation</title>
<properties>
<property name="sys:locale">
<title>Locale</title>
<type>d:locale</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
</aspects>
</model>

View File

@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -241,6 +242,20 @@ public class PropertyValue implements Cloneable, Serializable
{
return DefaultTypeConverter.INSTANCE.convert(Path.class, value);
}
},
LOCALE
{
@Override
protected ValueType getPersistedType(Serializable value)
{
return ValueType.STRING;
}
@Override
Serializable convert(Serializable value)
{
return DefaultTypeConverter.INSTANCE.convert(Locale.class, value);
}
};
/**
@@ -343,6 +358,10 @@ public class PropertyValue implements Cloneable, Serializable
{
return ValueType.PATH;
}
else if (value instanceof Locale)
{
return ValueType.LOCALE;
}
else
{
// type is not recognised as belonging to any particular slot
@@ -373,6 +392,7 @@ public class PropertyValue implements Cloneable, Serializable
valueTypesByPropertyType.put(DataTypeDefinition.ASSOC_REF, ValueType.ASSOC_REF);
valueTypesByPropertyType.put(DataTypeDefinition.PATH, ValueType.PATH);
valueTypesByPropertyType.put(DataTypeDefinition.QNAME, ValueType.QNAME);
valueTypesByPropertyType.put(DataTypeDefinition.LOCALE, ValueType.LOCALE);
}
/** the type of the property, prior to serialization persistence */

View File

@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -106,6 +107,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
public static final QName PROP_QNAME_CONTENT_VALUE = QName.createQName(NAMESPACE, "contentValue");
public static final QName PROP_QNAME_PATH_VALUE = QName.createQName(NAMESPACE, "pathValue");
public static final QName PROP_QNAME_CATEGORY_VALUE = QName.createQName(NAMESPACE, "categoryValue");
public static final QName PROP_QNAME_LOCALE_VALUE = QName.createQName(NAMESPACE, "localeValue");
public static final QName PROP_QNAME_NULL_VALUE = QName.createQName(NAMESPACE, "nullValue");
public static final QName PROP_QNAME_MULTI_VALUE = QName.createQName(NAMESPACE, "multiValue");
public static final QName PROP_QNAME_PROP1 = QName.createQName(NAMESPACE, "prop1");
@@ -1014,6 +1016,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
properties.put(PROP_QNAME_PATH_VALUE, pathProperty);
properties.put(PROP_QNAME_CONTENT_VALUE, new ContentData("url", "text/plain", 88L, "UTF-8"));
properties.put(PROP_QNAME_CATEGORY_VALUE, rootNodeRef);
properties.put(PROP_QNAME_LOCALE_VALUE, Locale.CHINESE);
properties.put(PROP_QNAME_NULL_VALUE, null);
properties.put(PROP_QNAME_MULTI_VALUE, listProperty);

View File

@@ -259,6 +259,10 @@
<type>d:category</type>
<mandatory>true</mandatory>
</property>
<property name="test:localeValue">
<type>d:locale</type>
<mandatory>true</mandatory>
</property>
<property name="test:nullValue">
<type>d:text</type>
<mandatory>true</mandatory>

View File

@@ -49,6 +49,7 @@ public interface DataTypeDefinition
public QName CHILD_ASSOC_REF = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "childassocref");
public QName ASSOC_REF = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "assocref");
public QName PATH = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "path");
public QName LOCALE = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "locale");
/**

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.ml;
import java.util.Locale;
import org.alfresco.service.Auditable;
import org.alfresco.service.PublicService;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* The API to manage multilingual content and related structures.
*
* @author Derek Hulley
*/
@PublicService
public interface MultilingualContentService
{
/**
* Rename an existing <b>cm:translation</b> by adding locale suffixes to the base name.
* Where there are name clashes with existing documents, a numerical naming scheme will be
* adopted.
*
* @param translationNodeRef An existing <b>cm:translation</b>
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"translationNodeRef"})
void renameWithMLExtension(NodeRef translationNodeRef);
/**
* Make an existing document translatable. If it is already translatable, then nothing is done.
*
* @param contentNodeRef An existing <b>cm:content</b>
* @return Returns the <b>cm:mlContainer</b> translation parent
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contentNodeRef", "locale"})
NodeRef makeTranslatable(NodeRef contentNodeRef, Locale locale);
/**
* Make a translation out of an existing document. The necessary translation structures will be created
* as necessary.
*
* @param newTranslationNodeRef An existing <b>cm:content</b>
* @param translationOfNodeRef An existing <b>cm:translation</b> or <b>cm:mlContainer</b>
* @return Returns the <b>cm:mlContainer</b> translation parent
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"newTranslationNodeRef", "translationOfNodeRef", "locale"})
NodeRef addTranslation(NodeRef newTranslationNodeRef, NodeRef translationOfNodeRef, Locale locale);
/**
*
* @return Returns the <b>cm:mlContainer</b> translation parent
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"translationNodeRef"})
NodeRef getTranslationContainer(NodeRef translationNodeRef);
/**
* Create a new edition of an existing <b>cm:mlContainer</b>.
*
* @param mlContainerNodeRef An existing <b>cm:mlContainer</b>
* @param translationNodeRef The specific <b>cm:translation</b> to use as the starting point
* of the new edition.
* @return Returns the <b>cm:mlContainer</b>
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"mlContainerNodeRef", "translationNodeRef"})
NodeRef createEdition(NodeRef mlContainerNodeRef, NodeRef translationNodeRef);
}

View File

@@ -28,8 +28,10 @@ import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
@@ -268,7 +270,28 @@ public class DefaultTypeConverter
}
});
INSTANCE.addConverter(String.class, Locale.class, new TypeConverter.Converter<String, Locale>()
{
public Locale convert(String source)
{
return I18NUtil.parseLocale(source);
}
});
//
// From Locale
//
INSTANCE.addConverter(Locale.class, String.class, new TypeConverter.Converter<Locale, String>()
{
public String convert(Locale source)
{
return source.toString();
}
});
//
// From MLText
//