CategoryLocalization
EditForm angebunden. Verknüpfung funktioniert, mit einer Ausnahme: der Parameter für die Sprachvariante wird noch nicht erkann und erzeugt daher einen Assert-Fehler. git-svn-id: https://svn.libreccm.org/ccm/trunk@1808 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b3105ac2e8
commit
8aea372fd5
|
|
@ -25,6 +25,7 @@ import com.arsdigita.bebop.Form;
|
|||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
|
|
@ -32,6 +33,7 @@ import com.arsdigita.bebop.event.ActionListener;
|
|||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.categorization.CategorizedCollection;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryCollection;
|
||||
|
|
@ -80,6 +82,8 @@ class CategoryItemPane extends BaseItemPane {
|
|||
private final SingleSelectionModel m_model;
|
||||
private final CategoryRequestLocal m_category;
|
||||
private final SimpleContainer m_detailPane;
|
||||
private final StringParameter m_catLocaleParam = new StringParameter("catLocale");
|
||||
private final ParameterSingleSelectionModel m_catLocale;
|
||||
|
||||
public CategoryItemPane(final SingleSelectionModel model,
|
||||
final CategoryRequestLocal category,
|
||||
|
|
@ -88,9 +92,9 @@ class CategoryItemPane extends BaseItemPane {
|
|||
final ActionLink deleteLink) {
|
||||
m_model = model;
|
||||
m_category = category;
|
||||
m_catLocale = new ParameterSingleSelectionModel(m_catLocaleParam);
|
||||
|
||||
// Details
|
||||
|
||||
m_detailPane = new SimpleContainer();
|
||||
add(m_detailPane);
|
||||
setDefault(m_detailPane);
|
||||
|
|
@ -145,7 +149,8 @@ class CategoryItemPane extends BaseItemPane {
|
|||
m_category.getCategory(state)
|
||||
.getCategoryLocalizationCollection().size();
|
||||
|
||||
if (countLanguages < countSupportedLanguages) {
|
||||
if (m_category.getCategory(state).canEdit()
|
||||
&& countLanguages < countSupportedLanguages) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -339,14 +344,14 @@ class CategoryItemPane extends BaseItemPane {
|
|||
|
||||
final ActionGroup group = new ActionGroup();
|
||||
setBody(group);
|
||||
m_catLocalizationTable = new CategoryLocalizationTable(m_category, m_model);
|
||||
m_catLocalizationTable = new CategoryLocalizationTable(m_category, m_model, m_catLocale);
|
||||
group.setSubject(m_catLocalizationTable);
|
||||
group.addAction(new AdminVisible(addLink), ActionGroup.ADD);
|
||||
|
||||
m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, "de");
|
||||
m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, m_catLocale);
|
||||
add(m_editCategoryLocalizationForm);
|
||||
connect(m_editCategoryLocalizationForm);
|
||||
connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -593,6 +598,7 @@ class CategoryItemPane extends BaseItemPane {
|
|||
* and the user is allowed to edit this item.
|
||||
*
|
||||
* @param state
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -614,6 +620,7 @@ class CategoryItemPane extends BaseItemPane {
|
|||
*
|
||||
* @param item
|
||||
* @param state
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isItemEditable(ContentItem item, PageState state) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.arsdigita.cms.ui.category;
|
|||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
|
|
@ -44,19 +45,16 @@ public class CategoryLocalizationEditForm extends CategoryLocalizationForm {
|
|||
private static final Logger s_log = Logger.getLogger
|
||||
(CategoryLocalizationEditForm.class);
|
||||
|
||||
private final String m_categoryLocalizationLocale;
|
||||
|
||||
private final SingleSelectionModel m_catLocale;
|
||||
/**
|
||||
* Creates a new instance of CategoryLocalizationEditForm
|
||||
*/
|
||||
public CategoryLocalizationEditForm(final CategoryRequestLocal category,
|
||||
final String locale) {
|
||||
public CategoryLocalizationEditForm(final CategoryRequestLocal category, SingleSelectionModel catLocale) {
|
||||
|
||||
super("EditCategoryLocalization", gz(
|
||||
"cms.ui.category.localization_edit"), category);
|
||||
|
||||
// Speichere Locale ab
|
||||
m_categoryLocalizationLocale = locale;
|
||||
m_catLocale = catLocale;
|
||||
|
||||
addInitListener(new InitListener());
|
||||
addProcessListener(new ProcessListener());
|
||||
|
|
@ -73,19 +71,20 @@ public class CategoryLocalizationEditForm extends CategoryLocalizationForm {
|
|||
final PageState state = e.getPageState();
|
||||
final Category category = m_category.getCategory(state);
|
||||
|
||||
final String categoryLocalizationLocale = (String) m_catLocale.getSelectedKey(state);
|
||||
|
||||
// Hide Locale-Widget and lock it (read-only)
|
||||
m_locale.addOption(new Option(m_categoryLocalizationLocale,
|
||||
new Locale(m_categoryLocalizationLocale).getDisplayLanguage()), state);
|
||||
// m_locale.setValue(state, m_categoryLocalizationLocale);
|
||||
m_locale.addOption(new Option(categoryLocalizationLocale,
|
||||
new Locale(categoryLocalizationLocale).getDisplayLanguage()), state);
|
||||
m_locale.setValue(state, categoryLocalizationLocale);
|
||||
// m_locale.setVisible(state, false);
|
||||
m_locale.lock();
|
||||
|
||||
m_name.setValue(state, category.getName((String) m_locale.getValue(state)));
|
||||
m_description.setValue(state, category.getDescription(
|
||||
(String) m_locale.getValue(state)));
|
||||
m_url.setValue(state, category.getURL((String) m_locale.getValue(state)));
|
||||
m_name.setValue(state, category.getName(categoryLocalizationLocale));
|
||||
m_description.setValue(state, category.getDescription(categoryLocalizationLocale));
|
||||
m_url.setValue(state, category.getURL(categoryLocalizationLocale));
|
||||
|
||||
if (category.isEnabled((String) m_locale.getValue(state))) {
|
||||
if (category.isEnabled(categoryLocalizationLocale)) {
|
||||
m_isEnabled.setValue(state, "yes");
|
||||
} else {
|
||||
m_isEnabled.setValue(state, "no");
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@ package com.arsdigita.cms.ui.category;
|
|||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
|
|
@ -36,13 +34,7 @@ import com.arsdigita.bebop.table.TableModelBuilder;
|
|||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryLocalization;
|
||||
import com.arsdigita.categorization.CategoryLocalizationCollection;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
|
@ -61,22 +53,23 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
private final SingleSelectionModel m_model;
|
||||
private final String TABLE_COL_LANG = "table_col_lang";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final SingleSelectionModel m_catLocale;
|
||||
|
||||
/**
|
||||
* Creates a new instance of CategoryLocalizationTable
|
||||
*/
|
||||
public CategoryLocalizationTable(final CategoryRequestLocal category,
|
||||
final SingleSelectionModel model) {
|
||||
public CategoryLocalizationTable(final CategoryRequestLocal category, final SingleSelectionModel model, SingleSelectionModel catLocale) {
|
||||
|
||||
super();
|
||||
|
||||
m_category = category;
|
||||
m_model = model;
|
||||
m_catLocale = catLocale;
|
||||
|
||||
// if table is empty:
|
||||
setEmptyView(new Label(GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_none")));
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
|
||||
// define columns
|
||||
// XXX globalize
|
||||
|
|
@ -196,25 +189,15 @@ TableColumnModel tab_model = getColumnModel();
|
|||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
boolean isSelected, final Object key,
|
||||
int row, int column) {
|
||||
|
||||
|
||||
// if (canEdit) {
|
||||
// CategoryLocalization cl;
|
||||
|
||||
// try {
|
||||
// cl = new CategoryLocalization((BigDecimal) key);
|
||||
// } catch (DataObjectNotFoundException ex) {
|
||||
// return new Label(value.toString());
|
||||
// }
|
||||
|
||||
// ContentSection section = CMS.getContext().getContentSection();
|
||||
// ItemResolver resolver = section.getItemResolver();
|
||||
|
||||
// return new Link(value.toString(), resolver.generateItemURL(state, cl, section, cl.getVersion()));
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
if (m_category.getCategory(state).canEdit()) {
|
||||
return new ControlLink(value.toString());
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,10 +207,14 @@ TableColumnModel tab_model = getColumnModel();
|
|||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
if (m_category.getCategory(state).canDelete()) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_confirm_delete").localize());
|
||||
return link;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,6 +239,7 @@ TableColumnModel tab_model = getColumnModel();
|
|||
|
||||
// Edit
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_LANG)) {
|
||||
m_catLocale.setSelectedKey(state, categoryLocalization.getLocale());
|
||||
}
|
||||
|
||||
// Delete
|
||||
|
|
|
|||
|
|
@ -106,15 +106,18 @@ public class Category extends ACSObject {
|
|||
private static final Logger s_log = Logger.getLogger(Category.class);
|
||||
/**
|
||||
* @see ObjectType
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.categorization.Category";
|
||||
private static final String BASE_DATA_OBJECT_PACKAGE =
|
||||
"com.arsdigita.categorization";
|
||||
/**
|
||||
* The <code>PrivilegeDescriptor corresponding</code> to the privilege to
|
||||
* The
|
||||
* <code>PrivilegeDescriptor corresponding</code> to the privilege to
|
||||
* map subcategories and objects to this category
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public static final PrivilegeDescriptor MAP_DESCRIPTOR =
|
||||
new PrivilegeDescriptor(
|
||||
"map_to_category");
|
||||
|
|
@ -128,38 +131,64 @@ public class Category extends ACSObject {
|
|||
public static final String ROOT_USE_CONTEXT = "rootUseContext";
|
||||
public static final String OWNER_USE_CONTEXT = "ownerUseContext";
|
||||
// category-category mapping types
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String CHILD = "child";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String PARENTS = "parents";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String RELATED = "related";
|
||||
public static final String PREFERRED = "preferred";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String REL_TYPE = "relationType";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String SORT_KEY = "sortKey";
|
||||
public static final String IS_DEFAULT = "isDefault";
|
||||
public static final String IS_INDEX = "isIndex";
|
||||
public static final String PARENT_CATEGORY = "parentCategory";
|
||||
public static final String CATEGORY_ID = "categoryID";
|
||||
// these are some constants to use in the code
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String NAME = "name";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String DESCRIPTION = "description";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String URL = "url";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String IS_ENABLED = "isEnabled";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String IS_ABSTRACT = "isAbstract";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String DEFAULT_ANCESTORS = "defaultAncestors";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
public static final String IGNORE_PARENT_INDEX_ITEM =
|
||||
"ignoreParentIndexItem";
|
||||
/** An attribute name for the underlying data object. */
|
||||
/**
|
||||
* An attribute name for the underlying data object.
|
||||
*/
|
||||
private static final String PURPOSES = "purposes";
|
||||
// this contains association names from the pdl file
|
||||
public final static String CHILD_OBJECTS = "childObjects";
|
||||
|
|
@ -183,7 +212,8 @@ public class Category extends ACSObject {
|
|||
|
||||
/**
|
||||
* Returns the model name of {@link #BASE_DATA_OBJECT_TYPE}.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public static String getBaseDataObjectPackage() {
|
||||
return BASE_DATA_OBJECT_PACKAGE;
|
||||
}
|
||||
|
|
@ -192,7 +222,8 @@ public class Category extends ACSObject {
|
|||
* Initializes the category with the specified data object.
|
||||
*
|
||||
* @param categoryObjectData the data object
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public Category(DataObject categoryObjectData) {
|
||||
super(categoryObjectData);
|
||||
}
|
||||
|
|
@ -202,7 +233,8 @@ public class Category extends ACSObject {
|
|||
* Category(Category.BSE_DATA_OBJECT_TYPE)}.
|
||||
*
|
||||
* @see com.arsdigita.domain.DomainObject#DomainObject(String)
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public Category() {
|
||||
this(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
|
@ -216,7 +248,8 @@ public class Category extends ACSObject {
|
|||
* @see com.arsdigita.domain.DomainObject#DomainObject(String)
|
||||
* @see com.arsdigita.persistence.DataObject
|
||||
* @see com.arsdigita.persistence.metadata.ObjectType
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public Category(String typeName) {
|
||||
super(typeName);
|
||||
}
|
||||
|
|
@ -229,7 +262,8 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* @see com.arsdigita.domain.DomainObject#DomainObject(ObjectType)
|
||||
* @see com.arsdigita.persistence.DataObject
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public Category(ObjectType type) {
|
||||
super(type);
|
||||
}
|
||||
|
|
@ -239,12 +273,14 @@ public class Category extends ACSObject {
|
|||
* storage mechanism.
|
||||
*
|
||||
* @param oid the OID for the data object to retrieve
|
||||
*
|
||||
* @throws DataObjectNotFoundException if this OID is invalid or has been
|
||||
* deleted.
|
||||
*
|
||||
* @see com.arsdigita.domain.DomainObject#DomainObject(OID)
|
||||
* @see com.arsdigita.persistence.DataObject
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public Category(OID oid) {
|
||||
super(oid);
|
||||
}
|
||||
|
|
@ -295,6 +331,7 @@ public class Category extends ACSObject {
|
|||
* @param categoryID the category ID
|
||||
* @param name the category name
|
||||
* @param description the category description
|
||||
*
|
||||
* @exception DataObjectNotFoundException if this OID is
|
||||
* invalid or has been deleted.
|
||||
*
|
||||
|
|
@ -315,6 +352,7 @@ public class Category extends ACSObject {
|
|||
* @param name the category name
|
||||
* @param description the category description
|
||||
* @param url URL component used when browsing categories.
|
||||
*
|
||||
* @exception DataObjectNotFoundException if this OID is
|
||||
* invalid or has been deleted.
|
||||
*
|
||||
|
|
@ -370,14 +408,15 @@ public class Category extends ACSObject {
|
|||
|
||||
/**
|
||||
* Quasimodo:
|
||||
* Returns the localized name or the name key if localized version don't exist
|
||||
* Returns the localized name or the name key if localized version don't
|
||||
* exist
|
||||
*
|
||||
* @return the category name.
|
||||
*/
|
||||
public String getName(String locale) {
|
||||
|
||||
// Test for localized version
|
||||
if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -404,6 +443,7 @@ public class Category extends ACSObject {
|
|||
/**
|
||||
* Returns the display name of the category. This overrides the parent
|
||||
* implementation.
|
||||
*
|
||||
* @return the category name.
|
||||
*/
|
||||
public String getDisplayName(String locale) {
|
||||
|
|
@ -413,6 +453,7 @@ public class Category extends ACSObject {
|
|||
/**
|
||||
* Returns the display name of the category. This overrides the parent
|
||||
* implementation.
|
||||
*
|
||||
* @return the category name.
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -464,12 +505,15 @@ public class Category extends ACSObject {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the <b>preferred</b> category along with its default ancestors.
|
||||
* Equivalent to #getQualifiedName(String,boolean) if this Category is not a synonym.
|
||||
* Returns the name of the <b>preferred</b> category along with its default
|
||||
* ancestors.
|
||||
* Equivalent to #getQualifiedName(String,boolean) if this Category is not a
|
||||
* synonym.
|
||||
* Synonym name is appended in parentheses.
|
||||
*
|
||||
* @param delimiter string to separate category names
|
||||
* @param includeRoot should root category be shown
|
||||
*
|
||||
* @return category path
|
||||
*/
|
||||
public String getPreferredQualifiedName(String delimiter,
|
||||
|
|
@ -495,7 +539,7 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* @param delimiter The string to use to seperate the parents from
|
||||
* the children.
|
||||
|
||||
*
|
||||
* @param includeRoot This indicates whether or not the root category should
|
||||
* be included in the URL.
|
||||
*/
|
||||
|
|
@ -549,7 +593,8 @@ public class Category extends ACSObject {
|
|||
* Returns the description of the category.
|
||||
*
|
||||
* Quasimodo:
|
||||
* Returns localized version of description or description key if localized version don't exist
|
||||
* Returns localized version of description or description key if localized
|
||||
* version don't exist
|
||||
*
|
||||
* @return the category description.
|
||||
*/
|
||||
|
|
@ -557,7 +602,7 @@ public class Category extends ACSObject {
|
|||
|
||||
// Test for localized version
|
||||
// HACK
|
||||
if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -576,6 +621,7 @@ public class Category extends ACSObject {
|
|||
|
||||
/**
|
||||
* Returns the description of the category.
|
||||
*
|
||||
* @return the category name.
|
||||
*/
|
||||
public String getDescription() {
|
||||
|
|
@ -587,7 +633,9 @@ public class Category extends ACSObject {
|
|||
* Returns a string repesenting the default ancestors of the category
|
||||
*
|
||||
* It can be useful and more efficient then working with the
|
||||
* CategoryCollection returned by @see getDefaultAscendants() when comparing
|
||||
* CategoryCollection returned by
|
||||
*
|
||||
* @see getDefaultAscendants() when comparing
|
||||
* ids whose position in the path is known.
|
||||
* (Added by Chris Gilbert)
|
||||
*/
|
||||
|
|
@ -623,14 +671,15 @@ public class Category extends ACSObject {
|
|||
* Returns the URL component of the category.
|
||||
*
|
||||
* Quasimodo:
|
||||
* Returns the localized version of the URL or URL-key if localized version don't exist
|
||||
* Returns the localized version of the URL or URL-key if localized version
|
||||
* don't exist
|
||||
*
|
||||
* @return URL component used when browsing categories
|
||||
*/
|
||||
public String getURL(String locale) {
|
||||
|
||||
// Test for localized version
|
||||
if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -696,16 +745,12 @@ public class Category extends ACSObject {
|
|||
*/
|
||||
public boolean isEnabled(String locale) {
|
||||
|
||||
// If locale is empty return global status
|
||||
// or if globally disabled, return category as disabled
|
||||
if (locale.isEmpty() || ((Boolean) get(IS_ENABLED)).booleanValue() == false) {
|
||||
return ((Boolean) get(IS_ENABLED)).booleanValue();
|
||||
}
|
||||
|
||||
// Test for localized version
|
||||
// HACK
|
||||
if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
// If not gloebally disabled and locale is not null or empty, test for localized version
|
||||
if (locale != null &&
|
||||
!locale.isEmpty() &&
|
||||
((Boolean) get(IS_ENABLED)).booleanValue() == true &&
|
||||
m_categoryLocalizationCollection != null &&
|
||||
m_categoryLocalizationCollection.localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
boolean isEnabled = m_categoryLocalizationCollection.isEnabled();
|
||||
|
|
@ -715,10 +760,8 @@ public class Category extends ACSObject {
|
|||
|
||||
} else {
|
||||
|
||||
// Return value of Category.getConfig().getShowInternalName()
|
||||
// This will disable all categories without selected locale, if Category.getConfig().getShowInternalName() == false
|
||||
return Category.getConfig().getShowInternalName();
|
||||
|
||||
// In any other case return global status
|
||||
return ((Boolean) get(IS_ENABLED)).booleanValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -783,7 +826,8 @@ public class Category extends ACSObject {
|
|||
* Determine whether this category should have a default index item
|
||||
* associated with it (i.e.it's parent category).
|
||||
*
|
||||
* @return <code>true</code> if the parent index item should be ignored (no default index item)
|
||||
* @return <code>true</code> if the parent index item should be ignored (no
|
||||
* default index item)
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean ignoreParentIndexItem() {
|
||||
|
|
@ -794,7 +838,8 @@ public class Category extends ACSObject {
|
|||
* Set whether this category should have a default index item
|
||||
* associated with it (i.e.it's parent category).
|
||||
*
|
||||
* @param ignoreParentIndexItem <code>true</code> if the parent index item should be ignored (no default index item)
|
||||
* @param ignoreParentIndexItem <code>true</code> if the parent index item
|
||||
* should be ignored (no default index item)
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public void setIgnoreParentIndexItem(boolean ignoreParentIndexItem) {
|
||||
|
|
@ -803,7 +848,8 @@ public class Category extends ACSObject {
|
|||
|
||||
/**
|
||||
* @deprecated use the "use context" APIs instead
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public Collection getPurposes() {
|
||||
DataAssociationCursor purposeCur = ((DataAssociation) get(PURPOSES)).
|
||||
cursor();
|
||||
|
|
@ -820,8 +866,10 @@ public class Category extends ACSObject {
|
|||
* Adds the specified purpose to this category.
|
||||
*
|
||||
* @param purpose The purpose
|
||||
*
|
||||
* @deprecated use the "use context" APIs instead
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void addPurpose(CategoryPurpose purpose) {
|
||||
add(PURPOSES, purpose);
|
||||
}
|
||||
|
|
@ -830,8 +878,10 @@ public class Category extends ACSObject {
|
|||
* Removes the specified purpose from this category.
|
||||
*
|
||||
* @param purpose the purpose
|
||||
*
|
||||
* @deprecated use the "use context" APIs instead
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void removePurpose(CategoryPurpose purpose) {
|
||||
remove(PURPOSES, purpose);
|
||||
}
|
||||
|
|
@ -941,7 +991,8 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* <p>If the category to be deleted is not the default parent of the child
|
||||
* category, this method deletes the mapping but it does not delete that
|
||||
* section of the subtree (similar to the way a UNIX <code>rm -r</code>
|
||||
* section of the subtree (similar to the way a UNIX
|
||||
* <code>rm -r</code>
|
||||
* works on symbolic links).
|
||||
*/
|
||||
public void deleteCategorySubtree() {
|
||||
|
|
@ -1055,7 +1106,8 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* @pre !isAbstract()
|
||||
* @pre canMap()
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void addChild(ACSObject object) {
|
||||
addMapping(object, "child");
|
||||
}
|
||||
|
|
@ -1075,16 +1127,19 @@ public class Category extends ACSObject {
|
|||
* categories and becomes a CHILD category.</p>
|
||||
*
|
||||
* @param category The related category
|
||||
*
|
||||
* @pre canMap()
|
||||
*
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void addRelatedCategory(Category category) {
|
||||
addMapping(category, RELATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a preferred category, which marks the current category as a synonym.
|
||||
* When a synonym category is selected, preferred category should be used instead
|
||||
* When a synonym category is selected, preferred category should be used
|
||||
* instead
|
||||
* i.e. assigned to the item.
|
||||
*/
|
||||
public void addPreferredCategory(Category preferred) {
|
||||
|
|
@ -1179,9 +1234,11 @@ public class Category extends ACSObject {
|
|||
* is no longer a child of a category. This actually deletes the mapping.
|
||||
*
|
||||
* @param acsObj the domain object to uncategorize
|
||||
*
|
||||
* @pre canMap()
|
||||
* @throws NullPointerException if <code>acsObj</code> is null
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void removeChild(ACSObject acsObj) {
|
||||
if (acsObj == null) {
|
||||
throw new NullPointerException("acsObj");
|
||||
|
|
@ -1198,7 +1255,8 @@ public class Category extends ACSObject {
|
|||
* Removes the specified child category.
|
||||
*
|
||||
* @throws NullPointerException if category is null
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void removeChild(Category category) {
|
||||
Assert.exists(category, Category.class);
|
||||
|
||||
|
|
@ -1305,7 +1363,8 @@ public class Category extends ACSObject {
|
|||
/**
|
||||
* Determines whether the category has child objects.
|
||||
*
|
||||
* @return <code>true</code> if the category does not have any child objects;
|
||||
* @return <code>true</code> if the category does not have any child
|
||||
* objects;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean hasChildObjects() {
|
||||
|
|
@ -1361,6 +1420,7 @@ public class Category extends ACSObject {
|
|||
* @param parent the category that will become the new
|
||||
* default category. Pass in null to clear the current
|
||||
* default parent.
|
||||
*
|
||||
* @exception CategoryNotFoundException if the passed in category is
|
||||
* not a parent of this category.
|
||||
*
|
||||
|
|
@ -1647,7 +1707,9 @@ public class Category extends ACSObject {
|
|||
* filter, if desired.
|
||||
*
|
||||
* @param relation The type of relation to retrieve.
|
||||
* @pre relation == Category.CHILD || relation == Category.RELATED || relation == Category.PREFERRED
|
||||
*
|
||||
* @pre relation == Category.CHILD || relation == Category.RELATED ||
|
||||
* relation == Category.PREFERRED
|
||||
*/
|
||||
public DataAssociationCursor getRelatedCategories(String relation) {
|
||||
Assert.isTrue(relation.equals(CHILD) || relation.equals(RELATED)
|
||||
|
|
@ -1677,7 +1739,8 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* @see #getDescendants()
|
||||
* @throws NullPointerException if objectType is null
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public CategoryCollection getChildren() {
|
||||
return new CategoryCollection(getRelatedCategories(CHILD));
|
||||
}
|
||||
|
|
@ -1688,7 +1751,8 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* @see #getObjects(String, String)
|
||||
* @throws NullPointerException if objectType is null
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public CategorizedCollection getObjects(String objectType) {
|
||||
return getObjects(objectType, null);
|
||||
}
|
||||
|
|
@ -1698,7 +1762,8 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* @param objectType the return collection will only contain objects of this
|
||||
* type
|
||||
* @param path the fragment of the PDL join path leading from the specified
|
||||
* @param path the fragment of the PDL join path leading from the
|
||||
* specified
|
||||
* object type to the <code>Category</code> object type. The common case
|
||||
* for CMS is to pass <code>"parent"</code> as the value of
|
||||
* <code>path</code>. The common scenario for many other applications is to
|
||||
|
|
@ -1708,7 +1773,8 @@ public class Category extends ACSObject {
|
|||
* @pre objectType!=null && path!=null
|
||||
* @post return != null
|
||||
* @throws NullPointerException if either parameter is null
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public CategorizedCollection getObjects(String objectType, String path) {
|
||||
if (objectType == null) {
|
||||
throw new NullPointerException("objectType");
|
||||
|
|
@ -1757,7 +1823,8 @@ public class Category extends ACSObject {
|
|||
/**
|
||||
* Returns the parent categories for this category (the categories under
|
||||
* which this category is categorized).
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public CategoryCollection getParents() {
|
||||
return new CategoryCollection(((DataAssociation) get(PARENTS)).cursor());
|
||||
}
|
||||
|
|
@ -1793,8 +1860,10 @@ public class Category extends ACSObject {
|
|||
* result.
|
||||
*
|
||||
* @param acsObject the item to search for
|
||||
*
|
||||
* @return <code>true</code> if the object appears mapped somewhere in
|
||||
* the subtree; <code>false</code> otherwise.
|
||||
*
|
||||
* @pre acsObject != null
|
||||
*/
|
||||
public boolean isMemberOfSubtree(ACSObject acsObject) {
|
||||
|
|
@ -1918,8 +1987,10 @@ public class Category extends ACSObject {
|
|||
* is the current category (hence the array will always have length >=
|
||||
* 1). If the path is bad, this returns <code>null</code>.
|
||||
*
|
||||
* This one may be patched to work with localized URLs. I didn't do it for now
|
||||
* because I don't know where it is called and if it's really needed to patch.
|
||||
* This one may be patched to work with localized URLs. I didn't do it for
|
||||
* now
|
||||
* because I don't know where it is called and if it's really needed to
|
||||
* patch.
|
||||
* Quasimodo
|
||||
*
|
||||
*/
|
||||
|
|
@ -2004,7 +2075,8 @@ public class Category extends ACSObject {
|
|||
|
||||
/**
|
||||
* Returns a collection of root categories to which this object is mapped.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public static RootCategoryCollection getRootCategories(ACSObject acsObj) {
|
||||
return new RootCategoryCollection(getRootCategoriesAssoc(acsObj));
|
||||
}
|
||||
|
|
@ -2012,7 +2084,8 @@ public class Category extends ACSObject {
|
|||
/**
|
||||
* Retrieves the root category associated with an object in the given use
|
||||
* context.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public static Category getRootForObject(ACSObject object, String context) {
|
||||
DataCollection cats = getRootCategoriesAssoc(object);
|
||||
|
||||
|
|
@ -2062,9 +2135,11 @@ public class Category extends ACSObject {
|
|||
*
|
||||
* <p>If <em>acsObj</em> is already mapped to some other category in the
|
||||
* specified use context, then the existing triple's category value is
|
||||
* updated to <code>rootCat</code>. Otherwise, a new triple is added.</p>
|
||||
* updated to
|
||||
* <code>rootCat</code>. Otherwise, a new triple is added.</p>
|
||||
*
|
||||
* <p>In theory, <code>rootCat</code> should be a root category, i.e. it
|
||||
* <p>In theory,
|
||||
* <code>rootCat</code> should be a root category, i.e. it
|
||||
* should have no parents. This method does not check if this is indeed the
|
||||
* case.</p>
|
||||
*
|
||||
|
|
@ -2116,16 +2191,19 @@ public class Category extends ACSObject {
|
|||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #clearRootForObject(ACSObject, String)} with the null context.
|
||||
* Calls {@link #clearRootForObject(ACSObject, String)} with the null
|
||||
* context.
|
||||
*
|
||||
* @see #clearRootForObject(ACSObject, String)
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public static void clearRootForObject(ACSObject object) {
|
||||
clearRootForObject(object, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes any root category associated with the object in the specified context.
|
||||
* Removes any root category associated with the object in the specified
|
||||
* context.
|
||||
*
|
||||
* @param object the object to remove the root category from
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue