DomainObject class to represent address ContentType
+ * objects.
+ *
+ * This content type represents a generic address which is not country specific.
+ * It provides methods for creating new address objects, retrieving existing
+ * objects from the persistent storage and retrieving and setting is properties.
This class extends {@link com.arsdigita.cms.ContentPage content page} and + * adds extended attributes specific for an not country specific address:
+ * + * @author Dominik Kacprzak + * @version $Revision: #6 $ $Date: 2004/08/17 $ + **/ +public class BaseAddress extends ContentItem { + + /** PDL property name for address */ + public static final String ADDRESS = "address"; + /** PDL property name for postal code */ + public static final String POSTAL_CODE = "postalCode"; + /** PDL property name for city */ + public static final String CITY = "city"; + /** PDL property name for state */ + public static final String STATE = "state"; + /** PDL property name for country iso code */ + public static final String ISO_COUNTRY_CODE = "isoCountryCode"; + + /** Data object type for this domain object */ + public static final String BASE_DATA_OBJECT_TYPE + = "com.arsdigita.cms.contenttypes.BaseAddress"; + + private static final BaseAddressConfig s_config = new BaseAddressConfig(); + static { + s_config.load(); + } + public static final BaseAddressConfig getConfig() + { + return s_config; + } + + /** + * Default constructor. This creates a new (empty) BaseAddress. + **/ + public BaseAddress() { + this(BASE_DATA_OBJECT_TYPE); + } + + /** + * Constructor. The containedDataObject is retrieved
+ * from the persistent storage mechanism with an OID
+ * specified by id and
+ * Address.BASE_DATA_OBJECT_TYPE.
+ *
+ * @param id The id for the retrieved
+ * DataObject.
+ **/
+ public BaseAddress(BigDecimal id) throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ /**
+ * Constructor. The contained DataObject is retrieved
+ * from the persistent storage mechanism with an OID
+ * specified by id.
+ *
+ * @param id The OID for the retrieved
+ * DataObject.
+ **/
+ public BaseAddress(OID id) throws DataObjectNotFoundException {
+ super(id);
+ }
+
+ /**
+ * Constructor. Retrieves or creates a content item using the
+ * DataObject argument.
+ *
+ * @param obj The DataObject with which to create or
+ * load a content item
+ */
+ public BaseAddress(DataObject obj) {
+ super(obj);
+ }
+
+ /**
+ * Constructor. Creates a new content item using the given data
+ * object type. Such items are created as draft versions.
+ *
+ * @param type The String data object type of the
+ * item to create
+ */
+ public BaseAddress(String type) {
+ super(type);
+ }
+
+ /**
+ * For new content items, sets the associated content type if it
+ * has not been already set.
+ */
+ public void beforeSave() {
+ super.beforeSave();
+
+ Assert.exists(getContentType(), ContentType.class);
+ }
+
+ /* accessors *****************************************************/
+ public String getAddress( ) {
+ return ( String ) get( ADDRESS );
+ }
+
+ public void setAddress( String address ) {
+ set( ADDRESS, address );
+ }
+
+ public String getIsoCountryCode( ) {
+ return ( String ) get( ISO_COUNTRY_CODE );
+ }
+
+ public void setIsoCountryCode( String isoCountryCode ) {
+ set( ISO_COUNTRY_CODE, isoCountryCode );
+ }
+
+ public String getPostalCode( ) {
+ return ( String ) get( POSTAL_CODE );
+ }
+
+ public void setPostalCode( String postalCode ) {
+ set( POSTAL_CODE, postalCode );
+ }
+
+ public String getCity( ) {
+ return ( String ) get( CITY );
+ }
+
+ public void setCity( String city ) {
+ set( CITY, city );
+ }
+
+ public String getState( ) {
+ return ( String ) get( STATE );
+ }
+
+ public void setState( String state ) {
+ set( STATE, state );
+ }
+
+}
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressConfig.java b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressConfig.java
new file mode 100644
index 000000000..e24e56c55
--- /dev/null
+++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressConfig.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+package com.arsdigita.cms.contenttypes;
+
+import com.arsdigita.runtime.AbstractConfig;
+import com.arsdigita.util.parameter.Parameter;
+import com.arsdigita.util.parameter.BooleanParameter;
+
+public class BaseAddressConfig extends AbstractConfig {
+
+ private final Parameter m_hideCountryCodeSelection;
+ private final Parameter m_hidePostalCode;
+
+ public BaseAddressConfig() {
+ m_hideCountryCodeSelection = new BooleanParameter(
+ "com.arsdigita.cms.contenttypes.address.hide_country_code_selection",
+ Parameter.REQUIRED,
+ new Boolean(false));
+
+ m_hidePostalCode = new BooleanParameter(
+ "com.arsdigita.cms.contenttypes.address.hide_postal_code",
+ Parameter.REQUIRED,
+ new Boolean(false));
+
+
+ register(m_hideCountryCodeSelection);
+ register(m_hidePostalCode);
+
+ loadInfo();
+ }
+
+ public final boolean getHideCountryCodeSelection() {
+ return ((Boolean) get(m_hideCountryCodeSelection)).booleanValue();
+ }
+ public final boolean getHidePostalCode() {
+ return ((Boolean) get(m_hidePostalCode)).booleanValue();
+ }
+}
+
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressConfig_parameter.properties b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressConfig_parameter.properties
new file mode 100644
index 000000000..62d3e7fdf
--- /dev/null
+++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressConfig_parameter.properties
@@ -0,0 +1,9 @@
+com.arsdigita.cms.contenttypes.address.hide_country_code_selection.title=Hide ISO Country Code
+com.arsdigita.cms.contenttypes.address.hide_country_code_selection.purpose=Hide the ISO country code selection box
+com.arsdigita.cms.contenttypes.address.hide_country_code_selection.example=false
+com.arsdigita.cms.contenttypes.address.hide_country_code_selection.format=[boolean]
+
+com.arsdigita.cms.contenttypes.address.hide_postal_code.title=Hide Postal Code
+com.arsdigita.cms.contenttypes.address.hide_postal_code.purpose=Hide the the postal code entry field
+com.arsdigita.cms.contenttypes.address.hide_postal_code.example=false
+com.arsdigita.cms.contenttypes.address.hide_postal_code.format=[boolean]
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressInitializer.java b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressInitializer.java
new file mode 100755
index 000000000..106b559c3
--- /dev/null
+++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressInitializer.java
@@ -0,0 +1,27 @@
+package com.arsdigita.cms.contenttypes;
+
+import org.apache.log4j.Logger;
+
+/**
+ * The CMS initializer
+ *
+ */
+public class BaseAddressInitializer extends ContentTypeInitializer {
+ public final static String versionId =
+ "$Id: BaseAddressInitializer.java $" +
+ "$Author: quasi $" +
+ "$DateTime: 2009/03/15 $";
+ private static final Logger s_log = Logger.getLogger(BaseAddressInitializer.class);
+
+ public BaseAddressInitializer() {
+ super("ccm-cms-types-baseAddress.pdl.mf",
+ BaseAddress.BASE_DATA_OBJECT_TYPE);
+ }
+
+ public String[] getStylesheets() {
+ return new String[] {
+ "/static/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xsl"
+ };
+ }
+
+}
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressLoader.java b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressLoader.java
new file mode 100755
index 000000000..0afcd64cb
--- /dev/null
+++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressLoader.java
@@ -0,0 +1,25 @@
+package com.arsdigita.cms.contenttypes;
+
+import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader;
+
+
+/**
+ * Loader
+ *
+ */
+public class BaseAddressLoader extends AbstractContentTypeLoader {
+ public final static String versionId =
+ "$Id: BaseAddressLoader.java$" +
+ "$Author: quasi $" +
+ "$DateTime: 2009/03/15 $";
+
+
+ private static final String[] TYPES = {
+ "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xml"
+ };
+
+ public String[] getTypes() {
+ return TYPES;
+ }
+
+}
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressResources.properties b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddressResources.properties
new file mode 100755
index 000000000..e69de29bb
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/util/BaseAddressGlobalizationUtil.java b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/util/BaseAddressGlobalizationUtil.java
new file mode 100755
index 000000000..55799ea20
--- /dev/null
+++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/util/BaseAddressGlobalizationUtil.java
@@ -0,0 +1,25 @@
+package com.arsdigita.cms.contenttypes.util;
+
+import com.arsdigita.globalization.GlobalizedMessage;
+
+public class BaseAddressGlobalizationUtil {
+
+ final public static String BUNDLE_NAME =
+ "com.arsdigita.cms.contenttypes.util.BaseAddressResourceBundle";
+
+ /**
+ * This returns a globalized message using the type specific bundle,
+ * BUNDLE_NAME
+ */
+ public static GlobalizedMessage globalize(String key) {
+ return new GlobalizedMessage(key, BUNDLE_NAME);
+ }
+
+ /**
+ * This returns a globalized message using the type specific bundle,
+ * BUNDLE_NAME
+ */
+ public static GlobalizedMessage globalize(String key, Object[] args) {
+ return new GlobalizedMessage(key, BUNDLE_NAME, args);
+ }
+}
diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/util/BaseAddressResourceBundle.java b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/util/BaseAddressResourceBundle.java
new file mode 100755
index 000000000..9983324ea
--- /dev/null
+++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/util/BaseAddressResourceBundle.java
@@ -0,0 +1,17 @@
+package com.arsdigita.cms.contenttypes.util;
+
+import java.util.PropertyResourceBundle;
+import com.arsdigita.globalization.ChainedResourceBundle;
+import com.arsdigita.cms.CMSGlobalized;
+
+public class BaseAddressResourceBundle extends ChainedResourceBundle implements CMSGlobalized {
+
+ public final static String BASE_ADDRESS_BUNDLE_NAME =
+ "com.arsdigita.cms.contenttypes.BaseAddressResources";
+
+ public BaseAddressResourceBundle() {
+ super();
+ addBundle((PropertyResourceBundle)getBundle(BASE_ADDRESS_BUNDLE_NAME));
+ addBundle((PropertyResourceBundle)getBundle(BUNDLE_NAME));
+ }
+}