DomainObject class to represent Contact ContentType
+ * objects.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: Contact.java 1689 2007-10-26 11:06:23Z chrisg23 $
+ */
+public class Contact extends ContentPage {
+
+ /** PDL property names */
+ /*
+ * Flattened out Person object properties.Next 3 properties can be moved out
+ * to seperate object if needed.
+ */
+ public static final String GIVEN_NAME = "givenName";
+ public static final String FAMILY_NAME = "familyName";
+ public static final String SUFFIX = "suffix";
+ public static final String EMAILS = "emails";
+
+ public static final String DESCRIPTION = "description";
+ public static final String ORG_NAME = "orgName";
+ public static final String DEPT_NAME = "deptName";
+ public static final String ROLE = "role";
+
+ /* Composite objects used by this class */
+ public static final String CONTACT_TYPE = "contactType";
+ public static final String CONTACT_ADDRESS = "contactAddress";
+ public static final String PHONES = "phones";
+
+ public static final String ITEMS = "associatedContentItemsForContact";
+
+ private static final Logger s_log = Logger.getLogger(Contact.class);
+
+ /** data object type for this domain object */
+ public static final String BASE_DATA_OBJECT_TYPE =
+ "com.arsdigita.cms.contenttypes.Contact";
+
+ /** Default constructor. */
+ public Contact() {
+ super(BASE_DATA_OBJECT_TYPE);
+ }
+
+ /**
+ * Adds an association between this contact and the given content item.
+ * @param item
+ */
+ public void addContentItem(ContentItem item) {
+ s_log.debug("item is " + item);
+ item.addToAssociation(getItemsForContact());
+ }
+
+ /**
+ * Deletes the association between this contact and the given content item.
+ * @param item
+ */
+ public void removeContentItem(ContentItem item) {
+ s_log.debug("item is " + item);
+ DataOperation operation = SessionManager
+ .getSession()
+ .retrieveDataOperation(
+ "com.arsdigita.cms.contenttypes.removeContactFromContentItemAssociation");
+ operation.setParameter("itemID", new Integer(item.getID().intValue()));
+ operation.execute();
+ }
+
+ /**
+ * Removes all mappings between this contact and any other content item.
+ *
+ */
+ private void removeItemMappings() {
+ DataOperation operation = SessionManager
+ .getSession()
+ .retrieveDataOperation(
+ "com.arsdigita.cms.contenttypes.removeContactFromAllAssociations");
+ operation.setParameter("contactID", new Integer(this.getID().intValue()));
+ operation.execute();
+ }
+
+
+ /**
+ * Gets the DataAssociation that holds the mapping between this contact
+ * and any content items.
+ * @return
+ */
+ public DataAssociation getItemsForContact() {
+ return (DataAssociation) get(ITEMS);
+ }
+
+
+ /**
+ * Returns the Contact for a given content item.
+ * @param item
+ * @return
+ */
+ public static Contact getContactForItem(ContentItem item) {
+ s_log.debug("getting contact for item " + item);
+ DataQuery query = SessionManager.getSession().retrieveQuery(
+ "com.arsdigita.cms.contenttypes.getContactForItem");
+ query.setParameter("itemID", item.getID());
+ BigDecimal contactID;
+ Contact contact = null;
+ while (query.next()) {
+ contactID = (BigDecimal) query.get("contactID");
+ contact = new Contact(contactID);
+ }
+ s_log.debug("returning contact " + contact);
+ return contact;
+ }
+
+
+
+
+ /**
+ * Constructor. Retrieves an object instance with the given id.
+ * @param id the id of the object to retrieve
+ */
+ public Contact( BigDecimal id ) throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given OID.
+ *
+ * @param oid the object id of the object to retrieve
+ */
+ public Contact(OID oid) throws DataObjectNotFoundException {
+ super(oid);
+ }
+
+ /**
+ * Constructor. Create a Contact domain object using the given data object.
+ * @param obj the object data to use
+ */
+ public Contact( DataObject obj ) {
+ super(obj);
+ }
+
+ /** Constructor. */
+ public Contact( String type ) {
+ super(type);
+ }
+
+ public void beforeSave() {
+ super.beforeSave();
+
+ Assert.exists(getContentType(), ContentType.class);
+ }
+
+ public String getBaseDataObjectType() {
+ return BASE_DATA_OBJECT_TYPE;
+ }
+
+ /** Accessor. Get the GIVEN_NAME for this Contact. */
+ public String getGivenName(){
+ return (String) get(GIVEN_NAME);
+ }
+
+ /** Mutator. Set the GIVEN_NAME for this Contact. */
+ public void setGivenName(String gn){
+ set(GIVEN_NAME , gn);
+ }
+
+ /** Accessor. Get the FAMILY_NAME for this Contact. */
+ public String getFamilyName(){
+ return (String) get(FAMILY_NAME);
+ }
+
+ /** Mutator. Set the FAMILY_NAME for this Contact. */
+ public void setFamilyName(String fn){
+ set(FAMILY_NAME , fn);
+ }
+
+ /** Accessor. Get the SUFFIX for this Contact. */
+ public String getSuffix(){
+ return (String) get(SUFFIX);
+ }
+
+ /** Mutator. Set the DESCRIPTION for this Contact. */
+ public void setSuffix(String suf){
+ set(SUFFIX , suf);
+ }
+
+ /** Accessor. Get the EMAILS for this Contact. */
+ public String getEmails(){
+ return (String) get(EMAILS);
+ }
+
+ /** Mutator. Set the EMAILS for this Contact. */
+ public void setEmails(String ems){
+ set(EMAILS , ems);
+ }
+
+ /** Accessor. Get the CONTACT_TYPE for this Contact. */
+ public String getContactTypeName() {
+ String ctTypeName = "";
+ if(getContactType() != null){
+ ctTypeName = getContactType().getTypeName();
+ }
+ return ctTypeName;
+ }
+
+ /** Accessor. Get the DESCRIPTION for this Contact. */
+ public String getDescription() {
+ return (String) get(DESCRIPTION);
+ }
+
+ /** Mutator. Set the DESCRIPTION for this Contact. */
+ public void setDescription( String desc ) {
+ set(DESCRIPTION , desc);
+ }
+
+ /** Accessor. Get the ORG_NAME for this Contact. */
+ public String getOrganisationName() {
+ return (String) get(ORG_NAME);
+ }
+
+ /** Mutator. Set the ORG_NAME for this Contact. */
+ public void setOrganisationName( String orgName ) {
+ set(ORG_NAME , orgName);
+ }
+
+ /** Accessor. Get the DEPT_NAME for this Contact. */
+ public String getDeptName() {
+ return (String) get(DEPT_NAME);
+ }
+
+ /** Mutator. Set the DEPT_NAME for this Contact. */
+ public void setDeptName( String deptName ) {
+ set(DEPT_NAME , deptName);
+ }
+
+ /** Accessor. Get the ROLE for this Contact. */
+ public String getRole() {
+ return (String) get(ROLE);
+ }
+
+ /** Mutator. Set the ROLE for this Contact. */
+ public void setRole( String role ) {
+ set(ROLE , role);
+ }
+
+ /**
+ * return type of Contact associated with this Contact object.
+ *
+ * @return null if there is no associated object.
+ */
+ public ContactType getContactType(){
+ DataObject obj = retrieveDataobject( CONTACT_TYPE );
+ if(obj != null){
+ return new ContactType(obj);
+ }
+ return null;
+ }
+
+ /** Mutator. Set the CONTACT_TYPE for this Contact. */
+ public void setContactType( ContactType ct ) {
+ setAssociation(CONTACT_TYPE , ct);
+ }
+
+/******* ContactAddress object manipulation methods *********************/
+ /**
+ * set the ContactAddress object association.
+ */
+ public void setContactAddress(ContactAddress caddr){
+ setAssociation(CONTACT_ADDRESS , caddr);
+ }
+
+ /**
+ * Get the associated ContactAddress object for this Contact.
+ * @return null if no Address is present.
+ */
+ public ContactAddress getContactAddress(){
+ DataObject obj = retrieveDataobject( CONTACT_ADDRESS);
+ if(obj != null){
+ return new ContactAddress(obj);
+ }
+ return null;
+ }
+
+ /******* ContactPhone object manipulation methods *********************/
+
+ /**
+ * Add a Phone object to the collection of the phone objects this contact
+ * has.
+ */
+ public void addPhone(ContactPhone ph){
+ add(PHONES , ph);
+ save();
+ }
+
+ /**
+ * Remove the passed in Phone object from the list of phones this contact
+ * object has.
+ */
+ public void removePhone(ContactPhone ph){
+ ph.delete();
+ save();
+ }
+
+ /**
+ * Return collection of Phone objects associated with this Contact object.
+ */
+ public PhonesCollection getPhones(){
+ DataAssociationCursor dac = ((DataAssociation) get(PHONES)).cursor();
+ return new PhonesCollection(dac);
+ }
+
+ private DataObject retrieveDataobject(String attr){
+ return ( DataObject ) get( attr );
+ }
+
+} //End of class.
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactAddress.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactAddress.java
new file mode 100755
index 000000000..af52ef25e
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactAddress.java
@@ -0,0 +1,171 @@
+/*
+ * 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 java.math.BigDecimal;
+
+import com.arsdigita.cms.ContentItem;
+import com.arsdigita.domain.DataObjectNotFoundException;
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.OID;
+
+/**
+ * DomainObject class to represent objects of type ContactAddress
+ * These objects are associated with Contact objects in this package.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactAddress.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactAddress extends ContentItem {
+
+ /** data object type for this domain object */
+ public static final String BASE_DATA_OBJECT_TYPE =
+ "com.arsdigita.cms.contenttypes.ContactAddress";
+
+ public static final String SAON = "saon";
+ public static final String PAON = "paon";
+ public static final String STREET_DESC = "streetDesc";
+ public static final String STREET_REF_NO = "streetRefNo";
+ public static final String LOCALITY = "locality";
+ public static final String TOWN = "town";
+ public static final String ADMINISTRATIVE_AREA = "administrativeArea";
+ public static final String POST_TOWN = "postTown";
+ public static final String POST_CODE = "postCode";
+ public static final String PROP_REF_NO = "referenceNo";
+
+ /** Default constructor. */
+ public ContactAddress() {
+ super(BASE_DATA_OBJECT_TYPE);
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given id.
+ * @param id the id of the object to retrieve
+ */
+ public ContactAddress(BigDecimal id) throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ /**
+ * Constructor. Create a Contact domain object using the given data object.
+ * @param obj the object data to use
+ */
+ public ContactAddress(DataObject obj) {
+ super(obj);
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given OID.
+ *
+ * @param oid the object id of the object to retrieve
+ */
+ public ContactAddress(OID oid) throws DataObjectNotFoundException {
+ super(oid);
+ }
+
+ /** Constructor. */
+ public ContactAddress( String type ) {
+ super(type);
+ }
+
+ public String getBaseDataObjectType() {
+ return BASE_DATA_OBJECT_TYPE;
+ }
+
+ public String getSaon() {
+ return (String) get(SAON);
+ }
+
+ public void setSaon(String saon) {
+ set(SAON,saon);
+ }
+
+ public String getPaon() {
+ return (String) get(PAON);
+ }
+
+ public void setPaon(String paon) {
+ set(PAON , paon);
+ }
+
+ public String getStreetDesc() {
+ return (String) get(STREET_DESC);
+ }
+
+ public void setStreetDesc(String desc) {
+ set(STREET_DESC,desc);
+ }
+
+ public String getStreetRefNo() {
+ return (String) get(STREET_REF_NO);
+ }
+
+ public void setStreetRefNo(String refno) {
+ set(STREET_REF_NO,refno);
+ }
+
+ public String getLocality() {
+ return (String) get(LOCALITY);
+ }
+
+ public void setLocality(String locality) {
+ set(LOCALITY,locality);
+ }
+
+ public String getTown() {
+ return (String) get(TOWN);
+ }
+
+ public void setTown(String town) {
+ set(TOWN,town);
+ }
+
+ public String getAdministrativeArea() {
+ return (String) get(ADMINISTRATIVE_AREA);
+ }
+
+ public void setAdministrativeArea(String adArea) {
+ set(ADMINISTRATIVE_AREA,adArea);
+ }
+
+ public String getPostTown() {
+ return (String) get(POST_TOWN);
+ }
+
+ public void setPostTown(String ptown) {
+ set(POST_TOWN, ptown);
+ }
+
+ public String getPostCode() {
+ return (String) get(POST_CODE);
+ }
+
+ public void setPostCode(String pcode) {
+ set(POST_CODE, pcode);
+ }
+
+ public String getReferenceNo() {
+ return (String) get(PROP_REF_NO);
+ }
+
+ public void setReferenceNo(String refno) {
+ set(PROP_REF_NO, refno);
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java
new file mode 100755
index 000000000..8c90e28da
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java
@@ -0,0 +1,122 @@
+/*
+ * 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 java.util.ArrayList;
+
+import com.arsdigita.cms.ContentPage;
+import com.arsdigita.cms.ContentSection;
+import com.arsdigita.cms.contenttypes.ui.contact.AddContactPropertiesStep;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+// import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter;
+import com.arsdigita.globalization.GlobalizedMessage;
+import com.arsdigita.runtime.DomainInitEvent;
+// import com.arsdigita.runtime.LegacyInitEvent;
+
+/**
+ * Initializer class to initialize ContentType Contact.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactInitializer.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactInitializer extends ContentTypeInitializer {
+
+ public ContactInitializer() {
+ super("ccm-ldn-types-contact.pdl.mf", Contact.BASE_DATA_OBJECT_TYPE);
+ }
+
+ public String[] getStylesheets() {
+ return new String [] {
+ "/static/content-types/com/arsdigita/cms/contenttypes/Contact.xsl",
+ };
+ }
+
+ public String getTraversalXML() {
+ return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Contact.xml";
+ }
+
+ private static ArrayList phoneTypesList = new ArrayList(10);
+
+ static {
+ phoneTypesList.add("Office");
+ phoneTypesList.add("Mobile");
+ phoneTypesList.add("Fax");
+ phoneTypesList.add("Home");
+ phoneTypesList.add("Minicom");
+ }
+
+ /**
+ * Return the statically initialized list of phone types.
+ */
+ public static ArrayList getPhoneTypes(){
+ return phoneTypesList;
+ }
+
+ // public void init(LegacyInitEvent evt) {
+ public void init(DomainInitEvent evt) {
+ super.init(evt);
+
+ if (ContentSection.getConfig().getHasContactsAuthoringStep()) {
+
+ // Add the "Contact"authoring step
+ AuthoringKitWizard.registerAssetStep(
+ getBaseType(),
+ getAuthoringStep(), getAuthoringStepLabel(),
+ getAuthoringStepDescription(), getAuthoringStepSortKey());
+
+ // and sort out the display - at the moment this is just the
+ // basic properties, addresses and phones
+ ContentItemTraversalAdapter associatedContactTraversalAdapter =
+ new ContentItemTraversalAdapter();
+ associatedContactTraversalAdapter.addAssociationProperty("/object/phones");
+ associatedContactTraversalAdapter.addAssociationProperty("/object/contactAddress");
+
+ ContentItemTraversalAdapter.registerAssetAdapter(
+ "associatedContactForItem",
+ associatedContactTraversalAdapter,
+ "com.arsdigita.cms.dispatcher.SimpleXMLGenerator");
+ }
+
+ }
+
+ private int getAuthoringStepSortKey() {
+ // TODO - workout what this does and possibly make it configurable
+ return 1;
+ }
+
+ private GlobalizedMessage getAuthoringStepDescription() {
+ return new GlobalizedMessage(
+ "com.arsdigita.cms.contenttypes.contact_authoring_step_description",
+ "com.arsdigita.cms.contenttypes.ContactResources");
+ }
+
+ private GlobalizedMessage getAuthoringStepLabel() {
+ return new GlobalizedMessage(
+ "com.arsdigita.cms.contenttypes.contact_authoring_step_label",
+ "com.arsdigita.cms.contenttypes.ContactResources");
+ }
+
+ private Class getAuthoringStep() {
+ return AddContactPropertiesStep.class;
+ }
+
+ private String getBaseType() {
+ return ContentPage.BASE_DATA_OBJECT_TYPE;
+ }
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactLoader.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactLoader.java
new file mode 100755
index 000000000..221a2a15d
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactLoader.java
@@ -0,0 +1,83 @@
+/*
+ * 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.ScriptContext;
+
+/**
+ * Loader for ContentType Contact.
+ *
+ * Also loads a fixed set of ContactType objects.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: ContactLoader.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class ContactLoader extends AbstractContentTypeLoader {
+
+ private static final String[] TYPES = {
+ "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Contact.xml"
+ };
+
+ /**
+ * @see com.arsdigita.cms.contenttypes.AbstractContentTypeLoader#getTypes()
+ */
+ public String[] getTypes() {
+ return TYPES;
+ }
+
+ /**
+ * @see com.arsdigita.runtime.Script#run(com.arsdigita.runtime.ScriptContext)
+ */
+ public void run(ScriptContext context) {
+ super.run(context);
+ loadContactTypes();
+ }
+
+ /**
+ * Create the fixed set of ContactTypes.
+ * This is a quick hack for now.If we need to extend it then we have
+ * to move it into an XML file and load it from initializer after
+ * checking it.
+ */
+ protected void loadContactTypes(){
+ ContactType ct = new ContactType();
+ ct.setName("ContactType-Service-Provision");
+ ct.setTypeName("Service Provision");
+ ct.save();
+
+ ct = new ContactType();
+ ct.setName("ContactType-Enquiry");
+ ct.setTypeName("Enquiry");
+ ct.save();
+
+ ct = new ContactType();
+ ct.setName("ContactType-Complaint");
+ ct.setTypeName("Complaint");
+ ct.save();
+
+ ct = new ContactType();
+ ct.setName("ContactType-Escalation");
+ ct.setTypeName("Escalation");
+ ct.save();
+
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java
new file mode 100755
index 000000000..007c8f0db
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java
@@ -0,0 +1,104 @@
+/*
+ * 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 java.math.BigDecimal;
+
+import com.arsdigita.cms.ContentItem;
+import com.arsdigita.domain.DataObjectNotFoundException;
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.OID;
+
+/**
+ * DomainObject class to represent objects of type ContactPhone.
+ * This object represents type of phone and it's number.
+ * They are associated with Contact objects.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: ContactPhone.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class ContactPhone extends ContentItem {
+
+ /** data object type for this domain object */
+ public static final String BASE_DATA_OBJECT_TYPE =
+ "com.arsdigita.cms.contenttypes.ContactPhone";
+
+ /** PDL property names */
+ public static final String PHONE_TYPE = "phoneType";
+ public static final String PHONE_NUMBER = "phoneNumber";
+
+ /** Default constructor. */
+ public ContactPhone() {
+ super(BASE_DATA_OBJECT_TYPE);
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given OID.
+ *
+ * @param oid the object id of the object to retrieve
+ */
+ public ContactPhone(OID oid) throws DataObjectNotFoundException {
+ super(oid);
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given id.
+ * @param id the id of the object to retrieve
+ */
+ public ContactPhone( BigDecimal id ) throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ /**
+ * Constructor. Create a Contact domain object using the given data object.
+ * @param obj the object data to use
+ */
+ public ContactPhone( DataObject obj ) {
+ super(obj);
+ }
+
+ /** Constructor. */
+ public ContactPhone( String type ) {
+ super(type);
+ }
+
+ public String getBaseDataObjectType() {
+ return BASE_DATA_OBJECT_TYPE;
+ }
+
+ //Accessors
+ public String getPhoneType(){
+ return (String) get(PHONE_TYPE);
+ }
+
+ public String getPhoneNumber(){
+ return (String) get(PHONE_NUMBER);
+ }
+
+ public void setPhoneNumber(String num){
+ set(PHONE_NUMBER,num);
+ }
+
+ public void setPhoneType(String type){
+ set(PHONE_TYPE, type);
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactResources.properties b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactResources.properties
new file mode 100755
index 000000000..5bf174903
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactResources.properties
@@ -0,0 +1,26 @@
+cms.contenttypes.ui.contact.address_saon=SAON
+cms.contenttypes.ui.contact.address_paon=PAON
+cms.contenttypes.ui.contact.address_streetdesc=Street Description
+cms.contenttypes.ui.contact.address_streetrefno=Street Reference No
+cms.contenttypes.ui.contact.address_locality=Locality
+cms.contenttypes.ui.contact.address_town=Town
+cms.contenttypes.ui.contact.address_administrative_area=Administrative Area
+cms.contenttypes.ui.contact.address_posttown=Postal Town
+cms.contenttypes.ui.contact.address_postcode=Postal Code
+cms.contenttypes.ui.contact.address_proprefno=Property Reference No
+cms.contenttypes.ui.contact_type=Contact Type
+cms.contenttypes.ui.contact_orgname=Organization Name
+cms.contenttypes.ui.contact_deptname=Department Name
+cms.contenttypes.ui.contact_role=Role of Contact
+cms.contenttypes.ui.contact_givenname=Given Name
+cms.contenttypes.ui.contact_familyname=Family Name
+cms.contenttypes.ui.contact_suffix=Suffix
+cms.contenttypes.ui.contact_description=Contact Description
+cms.contenttypes.ui.contact.phone_number=Number
+cms.contenttypes.ui.phone_type=Types
+cms.contenttypes.ui.contact_emails=Emails
+com.arsdigita.cms.contenttypes.contact_authoring_step_description=Contact
+com.arsdigita.cms.contenttypes.contact_authoring_step_label=Contact
+cms.contenttypes.ui.name=Name
+cms.contenttypes.ui.title=Title
+cms.contenttypes.ui.description=Description
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactType.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactType.java
new file mode 100755
index 000000000..b3cc2d81d
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactType.java
@@ -0,0 +1,90 @@
+/*
+ * 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 java.math.BigDecimal;
+
+import com.arsdigita.cms.ContentItem;
+import com.arsdigita.domain.DataObjectNotFoundException;
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.OID;
+
+/**
+ * DomainObject class to represent objects of ContactType.
+ * These objects are associated with Contact objects.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactType.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactType extends ContentItem {
+
+ /** data object type for this domain object */
+ public static final String BASE_DATA_OBJECT_TYPE =
+ "com.arsdigita.cms.contenttypes.ContactType";
+
+ public static final String TYPE_NAME = "typeName";
+
+ /** Default constructor. */
+ public ContactType() {
+ super(BASE_DATA_OBJECT_TYPE);
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given id.
+ * @param id the id of the object to retrieve
+ */
+ public ContactType( BigDecimal id ) throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ /**
+ * Constructor. Retrieves an object instance with the given OID.
+ *
+ * @param oid the object id of the object to retrieve
+ */
+ public ContactType(OID oid) throws DataObjectNotFoundException {
+ super(oid);
+ }
+
+ /**
+ * Constructor. Create a Contact domain object using the given data object.
+ * @param obj the object data to use
+ */
+ public ContactType( DataObject obj ) {
+ super(obj);
+ }
+
+ /** Constructor. */
+ public ContactType( String type ) {
+ super(type);
+ }
+
+ public String getBaseDataObjectType() {
+ return BASE_DATA_OBJECT_TYPE;
+ }
+
+ public String getTypeName(){
+ return (String) get(TYPE_NAME);
+ }
+
+ public void setTypeName(String tname){
+ set(TYPE_NAME,tname);
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactTypesCollection.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactTypesCollection.java
new file mode 100755
index 000000000..98761de1a
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactTypesCollection.java
@@ -0,0 +1,83 @@
+/*
+ * 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 java.math.BigDecimal;
+
+import com.arsdigita.domain.DomainCollection;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.persistence.DataCollection;
+import com.arsdigita.persistence.SessionManager;
+
+/**
+ * Class which represents a collection of ContactTypes.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactTypesCollection.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactTypesCollection extends DomainCollection {
+
+ /** Retrieve the collection of ContactTypes. */
+ public static ContactTypesCollection getContactTypesCollection(){
+ DataCollection typesColl = SessionManager.getSession().
+ retrieve(ContactType.BASE_DATA_OBJECT_TYPE);
+ return new ContactTypesCollection(typesColl);
+ }
+
+ /**
+ * private Constructor.Single ton type of class.
+ *
+ **/
+ private ContactTypesCollection(DataCollection dataCollection) {
+ super(dataCollection);
+ }
+
+ /**
+ * Returns a DomainObject for the current position in
+ * the collection.
+ *
+ **/
+ public DomainObject getDomainObject() {
+ return new ContactType(m_dataCollection.getDataObject());
+ }
+
+ /**
+ * Returns a ContactType for the current position in
+ * the collection.
+ *
+ **/
+ public ContactType getContactType() {
+ return (ContactType) getDomainObject();
+ }
+
+ /**
+ * Return the name of ContactType from current row.
+ */
+ public String getContactTypeName(){
+ return getContactType().getTypeName();
+ }
+
+ /**
+ * Return the ID of ContactType from current row.
+ */
+ public BigDecimal getContactTypeID(){
+ return getContactType().getID();
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/PhonesCollection.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/PhonesCollection.java
new file mode 100755
index 000000000..00840d1f5
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/PhonesCollection.java
@@ -0,0 +1,59 @@
+/*
+ * 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.domain.DomainCollection;
+import com.arsdigita.persistence.DataCollection;
+
+/**
+ * Collection of ContactPhoneS objects.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: PhonesCollection.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class PhonesCollection extends DomainCollection {
+
+ /**
+ * Constructor.
+ *
+ **/
+ public PhonesCollection(DataCollection dataCollection) {
+ super(dataCollection);
+ }
+
+ /**
+ * Returns a DomainObject for the current position in
+ * the collection.
+ *
+ **/
+ public ContactPhone getPhone() {
+ return new ContactPhone(m_dataCollection.getDataObject());
+ }
+
+ public String getPhoneType(){
+ return getPhone().getPhoneType();
+ }
+
+ public String getPhoneNumber(){
+ return getPhone().getPhoneNumber();
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/package.html b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/package.html
new file mode 100644
index 000000000..40dba4cb5
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/package.html
@@ -0,0 +1,23 @@
+
+
+
+Content type Contact
+
+
+
+
+Implementation of a Contact content type.
+
+Contact attributes include
+
+
+ - Given name, family name, title and other personal characteristics
+ - Contact type (e.g. service)
+ - Contact details as e-mail, oranisation name, etc.
+ - Address details (street, area, postal code, etc.y
+ - Phone (number and type) several may be added
+
+Because of these attributes this content type is especially useful for
+ United Kingdom residents and UK local authorities.
+
+
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddContactPropertiesStep.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddContactPropertiesStep.java
new file mode 100644
index 000000000..f46c94e57
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddContactPropertiesStep.java
@@ -0,0 +1,243 @@
+package com.arsdigita.cms.contenttypes.ui.contact;
+
+import org.apache.log4j.Logger;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.bebop.Form;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.FormSection;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.RequestLocal;
+import com.arsdigita.bebop.event.FormInitListener;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.util.GlobalizationUtil;
+import com.arsdigita.cms.ContentItem;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.ui.ResettableContainer;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
+import com.arsdigita.util.Assert;
+
+/**
+ *
+ */
+public class AddContactPropertiesStep extends ResettableContainer {
+
+ private static final Logger s_log = Logger
+ .getLogger(AddContactPropertiesStep.class);
+
+ public static final String EDIT_SHEET_NAME = "edit";
+
+ public Form m_form;
+
+ private ItemSelectionModel m_itemSelectionModel;
+
+ public ContactSelectionModel m_contactSelectionModel;
+
+ private AuthoringKitWizard m_parent;
+
+ protected Component m_contactPropertySheet;
+
+ private ContactDisplay m_display;
+
+ public AddContactPropertiesStep(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent) {
+
+ m_parent = parent;
+ m_itemSelectionModel = itemModel;
+ m_contactSelectionModel = new ContactSelectionModel(
+ m_itemSelectionModel);
+
+ Form display = new Form("display");
+ display.add(getContactDisplay());
+ add(display);
+
+ m_form = new Form("contactSearchForm");
+ m_form.add(getFindContactSheet());
+
+ WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel);
+ edit.add(m_form);
+ add(edit);
+
+ }
+
+ protected Component getContactDisplay() {
+ m_display = new ContactDisplay();
+ return m_display;
+ }
+
+ public void toggleDisplay(PageState state) throws FormProcessException {
+ m_display.toggle(state);
+ }
+
+ private Component getFindContactSheet() {
+ return new AddContactToItemForm(this);
+ }
+
+ public ItemSelectionModel getItemSelectionModel() {
+ return m_itemSelectionModel;
+ }
+
+ public ItemSelectionModel getContactSelectionModel() {
+ return m_contactSelectionModel;
+ }
+
+ public AuthoringKitWizard getParent() {
+ return m_parent;
+ }
+
+ public ContentItem getItem(PageState state) {
+ return m_itemSelectionModel.getSelectedItem(state);
+ }
+
+ public Contact getContact(PageState state) {
+ return (Contact) m_contactSelectionModel.getSelectedItem(state);
+ }
+
+ protected class ContactSelectionModel extends ItemSelectionModel {
+
+ private RequestLocal m_contact;
+
+ public ContactSelectionModel(ItemSelectionModel m) {
+ super(m);
+
+ m_contact = new RequestLocal() {
+ protected Object initialValue(PageState s) {
+ ContentItem item = (ContentItem) ((ItemSelectionModel) getSingleSelectionModel())
+ .getSelectedObject(s);
+ Assert.exists(item);
+ return Contact.getContactForItem(item);
+
+ }
+ };
+ }
+
+ public Object getSelectedKey(PageState s) {
+ Contact contact = (Contact) getSelectedObject(s);
+ return (contact == null) ? null : contact.getID();
+ }
+
+ public DomainObject getSelectedObject(PageState s) {
+ return (DomainObject) m_contact.get(s);
+ }
+
+ public void setSelectedObject(PageState s, DomainObject o) {
+ m_contact.set(s, o);
+ }
+
+ public void setSelectedKey(PageState s, Object key) {
+ throw new UnsupportedOperationException((String) GlobalizationUtil
+ .globalize("cms.ui.authoring.not_implemented").localize());
+ }
+
+ public boolean isSelected(PageState s) {
+ return (getSelectedObject(s) != null);
+ }
+ }
+
+ private class ContactDisplay extends FormSection implements
+ FormInitListener {
+
+ private Label m_noContact;
+
+ public ContactDisplay() {
+
+ addInitListener(this);
+ addWidgets();
+ }
+
+ public void toggle(PageState state) {
+ s_log.debug("toggle");
+ m_contactPropertySheet.setVisible(state, false);
+ m_noContact.setVisible(state, true);
+
+ }
+
+ private void addWidgets() {
+ m_contactPropertySheet = getContactPropertySheet(m_contactSelectionModel);
+ m_noContact = new Label("This item does not have a contact.");
+ m_noContact.setFontWeight(Label.ITALIC);
+ add(m_contactPropertySheet);
+ add(m_noContact);
+ }
+
+ public void init(FormSectionEvent e) throws FormProcessException {
+ s_log.debug("init");
+ PageState state = e.getPageState();
+ if (m_contactSelectionModel.getSelectedItem(state) != null) {
+ m_contactPropertySheet.setVisible(state, true);
+ m_noContact.setVisible(state, false);
+ } else {
+ m_noContact.setVisible(state, true);
+ m_contactPropertySheet.setVisible(state, false);
+ }
+
+ }
+
+ private Component getContactPropertySheet(ItemSelectionModel itemModel) {
+ DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
+ itemModel);
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.name"), Contact.NAME);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.title"), Contact.TITLE);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_givenname"),
+ Contact.GIVEN_NAME);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_familyname"),
+ Contact.FAMILY_NAME);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_type"),
+ Contact.CONTACT_TYPE,
+ new DomainObjectPropertySheet.AttributeFormatter() {
+ public String format(DomainObject item,
+ String attribute, PageState state) {
+ Contact contact = (Contact) item;
+ if (contact != null
+ && contact.getContactType() != null) {
+ return contact.getContactTypeName();
+ } else {
+ return "unknown";
+ }
+ }
+ });
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.description"),
+ Contact.DESCRIPTION);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_emails"),
+ Contact.EMAILS);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_suffix"),
+ Contact.SUFFIX);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_orgname"),
+ Contact.ORG_NAME);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_deptname"),
+ Contact.DEPT_NAME);
+
+ sheet.add(ContactGlobalizationUtil
+ .globalize("cms.contenttypes.ui.contact_role"),
+ Contact.ROLE);
+ return sheet;
+ }
+
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddContactToItemForm.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddContactToItemForm.java
new file mode 100644
index 000000000..1b3f92865
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddContactToItemForm.java
@@ -0,0 +1,151 @@
+package com.arsdigita.cms.contenttypes.ui.contact;
+
+import com.arsdigita.bebop.ActionLink;
+import com.arsdigita.bebop.ColumnPanel;
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.FormSection;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.SaveCancelSection;
+import com.arsdigita.bebop.event.ActionEvent;
+import com.arsdigita.bebop.event.ActionListener;
+import com.arsdigita.bebop.event.FormInitListener;
+import com.arsdigita.bebop.event.FormProcessListener;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.event.FormSubmissionListener;
+import com.arsdigita.bebop.event.FormValidationListener;
+import com.arsdigita.bebop.util.GlobalizationUtil;
+import com.arsdigita.cms.ContentItem;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.ui.ItemSearchWidget;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+
+public class AddContactToItemForm extends FormSection implements
+ FormInitListener, FormValidationListener, FormProcessListener,
+ FormSubmissionListener {
+
+ private ContentItem m_item;
+
+ private ItemSearchWidget m_itemSearch;
+
+ private SaveCancelSection m_saveCancelSection;
+
+ private ItemSelectionModel m_itemSelectionModel;
+
+ private final String CONTACT_SEARCH = "contact";
+
+ private Contact m_contact;
+
+ private Label m_searchFormLabel;
+
+ private AddContactPropertiesStep m_step;
+
+ private AuthoringKitWizard m_parent;
+
+ private Label m_removeLinkText = new Label(GlobalizationUtil
+ .globalize("Remove contact"));
+
+ private ActionLink m_removeLink;
+
+ public AddContactToItemForm(AddContactPropertiesStep step) {
+ m_step = step;
+ m_parent = m_step.getParent();
+
+ m_itemSelectionModel = m_step.getItemSelectionModel();
+ addInitListener(this);
+ addWidgets();
+ addSaveCancelSection();
+ addProcessListener(this);
+ addValidationListener(this);
+ addSubmissionListener(this);
+
+ }
+
+ public void addWidgets() {
+
+ m_removeLink = new ActionLink(m_removeLinkText);
+
+ m_removeLink.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ Contact contact = m_step.getContact(e.getPageState());
+ if (contact != null) {
+ PageState state = e.getPageState();
+ contact.removeContentItem(m_step.getItem(state));
+ m_step.m_contactSelectionModel.setSelectedObject(state,
+ null);
+ try {
+ m_step.toggleDisplay(state);
+ } catch (FormProcessException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+ });
+
+ add(m_removeLink, ColumnPanel.FULL_WIDTH);
+
+ m_searchFormLabel = new Label("Search for Contact:");
+ add(m_searchFormLabel);
+ m_itemSearch = new ItemSearchWidget(CONTACT_SEARCH,
+ Contact.BASE_DATA_OBJECT_TYPE);
+ add(m_itemSearch);
+ }
+
+ public AddContactToItemForm getThis() {
+ return this;
+ }
+
+ /** Adds the saveCancelSection */
+ public void addSaveCancelSection() {
+ m_saveCancelSection = new SaveCancelSection();
+ m_saveCancelSection.getSaveButton().setButtonLabel("Add");
+ add(m_saveCancelSection, ColumnPanel.FULL_WIDTH);
+ }
+
+ protected ContentItem getContentItem(PageState s) {
+ return (ContentItem) m_itemSelectionModel.getSelectedObject(s);
+ }
+
+ public void validate(FormSectionEvent e) throws FormProcessException {
+ FormData data = e.getFormData();
+ if (data.get(CONTACT_SEARCH) == null) {
+ throw new FormProcessException("Contact selection is required.");
+ }
+ }
+
+ public void process(FormSectionEvent e) throws FormProcessException {
+ FormData data = e.getFormData();
+ PageState ps = e.getPageState();
+ m_contact = (Contact) data.get(CONTACT_SEARCH);
+ m_contact.addContentItem(getContentItem(ps));
+ init(e);
+ }
+
+ public void submitted(FormSectionEvent e) throws FormProcessException {
+ if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
+ m_parent.reset(e.getPageState());
+ throw new FormProcessException("cancelled");
+ }
+ }
+
+ public void init(FormSectionEvent e) throws FormProcessException {
+ PageState ps = e.getPageState();
+ m_item = getContentItem(ps);
+ m_contact = Contact.getContactForItem(m_item);
+ if (m_contact != null) {
+ m_removeLink.setVisible(ps, true);
+ m_searchFormLabel.setVisible(ps, false);
+ m_itemSearch.setVisible(ps, false);
+ m_saveCancelSection.setVisible(ps, false);
+ } else {
+ m_removeLink.setVisible(ps, false);
+ m_searchFormLabel.setVisible(ps, true);
+ m_itemSearch.setVisible(ps, true);
+ m_saveCancelSection.setVisible(ps, true);
+ }
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddressProperties.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddressProperties.java
new file mode 100755
index 000000000..2b4329c38
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddressProperties.java
@@ -0,0 +1,115 @@
+/*
+ * 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.ui.contact;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.cms.ui.authoring.SimpleEditStep;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
+
+/**
+ * Authoring kit step to manipulate ContactAddress object
+ * associated with Contact object.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: AddressProperties.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class AddressProperties extends SimpleEditStep {
+
+ /** The name of the editing sheet added to this step */
+ public static String EDIT_SHEET_NAME = "edit-contact-address";
+
+ public AddressProperties(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent) {
+ super(itemModel, parent);
+
+ BasicItemForm form;
+
+ form = new AddressPropertyForm(itemModel);
+
+ add(EDIT_SHEET_NAME,
+ "Edit",
+ new WorkflowLockedComponentAccess(form, itemModel),
+ form.getSaveCancelSection().getCancelButton());
+
+ setDisplayComponent(getAddressPropertySheet(itemModel));
+ }
+
+ /**
+ * Returns a component that displays the properties of the Contact
+ * specified by the ItemSelectionModel passed in.
+ *
+ * @param itemModel The ItemSelectionModel to use
+ * @pre itemModel != null
+ * @return A component to display the state of the basic properties
+ * of the
+ **/
+ public static Component getAddressPropertySheet(ItemSelectionModel itemModel) {
+ DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_saon"),
+ "contactAddress.saon");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_paon"),
+ "contactAddress.paon");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_streetdesc"),
+ "contactAddress.streetDesc");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_streetrefno"),
+ "contactAddress.streetRefNo");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_locality"),
+ "contactAddress.locality");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_town"),
+ "contactAddress.town");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_administrative_area"),
+ "contactAddress.administrativeArea");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_posttown"),
+ "contactAddress.postTown");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_postcode"),
+ "contactAddress.postCode");
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_proprefno"),
+ "contactAddress.referenceNo");
+
+ return sheet;
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddressPropertyForm.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddressPropertyForm.java
new file mode 100755
index 000000000..9ea272b49
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/AddressPropertyForm.java
@@ -0,0 +1,223 @@
+/*
+ * 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.ui.contact;
+
+import org.apache.log4j.Logger;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
+import com.arsdigita.bebop.parameters.ParameterModel;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.ContactAddress;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+
+/**
+ * A form class to edit the properties of ContactAddress object.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: AddressPropertyForm.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class AddressPropertyForm extends BasicItemForm {
+
+ /** Name of this form */
+ private static final String ID = "Contact_address_edit";
+
+ private static final Logger s_log = Logger.getLogger(AddressPropertyForm.class);
+
+ /**
+ * Creates a new form to edit the ContactAddress object
+ * properties associated with the Contact object specified by
+ * the item selection model passed in.
+ *
+ * @param itemModel The ItemSelectionModel to use to obtain the Contact
+ * object to work on
+ **/
+ public AddressPropertyForm(ItemSelectionModel itemModel) {
+ super(ID, itemModel);
+ }
+
+ /**
+ * Adds widgets to edit the address properties to form.
+ * Only paon and streetDesc are required, rest are optional.
+ * This was cut down into small methods for subclasses to pick and choose.
+ **/
+ protected void addWidgets() {
+ addSAON();
+ addPAON();
+ addStreetDesc();
+ addStreetRefNo();
+ addLocality();
+ addTown();
+ addArea();
+ addPostTown();
+ addPostCode();
+ addPropRefNo();
+ }
+
+ protected void addSAON() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_saon")));
+ ParameterModel saonParam = new StringParameter(ContactAddress.SAON);
+ TextField saon = new TextField(saonParam);
+ add(saon);
+ }
+
+ protected void addPAON() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_paon")));
+ ParameterModel paonParam = new StringParameter(ContactAddress.PAON);
+ TextField paon = new TextField(paonParam);
+ paon.addValidationListener(new NotNullValidationListener());
+ add(paon);
+ }
+
+ protected void addStreetDesc() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_streetdesc")));
+ ParameterModel streetDescParam = new StringParameter(ContactAddress.STREET_DESC);
+ TextField streetDesc = new TextField(streetDescParam);
+ streetDesc.addValidationListener(new NotNullValidationListener());
+ add(streetDesc);
+ }
+
+ protected void addStreetRefNo() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_streetrefno")));
+ ParameterModel streetRefNoParam = new StringParameter(ContactAddress.STREET_REF_NO);
+ TextField streetRefNo = new TextField(streetRefNoParam);
+ add(streetRefNo);
+ }
+
+ protected void addLocality() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_locality")));
+ ParameterModel localityParam = new StringParameter(ContactAddress.LOCALITY);
+ TextField locality = new TextField(localityParam);
+ add(locality);
+ }
+
+ protected void addTown() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_town")));
+ ParameterModel townParam = new StringParameter(ContactAddress.TOWN);
+ TextField town = new TextField(townParam);
+ add(town);
+ }
+
+ protected void addArea() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_administrative_area")));
+ ParameterModel adAreaParam = new StringParameter(ContactAddress.ADMINISTRATIVE_AREA);
+ TextField adArea = new TextField(adAreaParam);
+ add(adArea);
+ }
+
+ protected void addPostTown() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_posttown")));
+ ParameterModel postTownParam = new StringParameter(ContactAddress.POST_TOWN);
+ TextField postTown = new TextField(postTownParam);
+ add(postTown);
+ }
+
+ protected void addPostCode() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_postcode")));
+ ParameterModel postCodeParam = new StringParameter(ContactAddress.POST_CODE);
+ TextField postCode = new TextField(postCodeParam);
+ add(postCode);
+ }
+
+ protected void addPropRefNo() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact.address_proprefno")));
+ ParameterModel propRefNoParam = new StringParameter(ContactAddress.PROP_REF_NO);
+ TextField propRefNo = new TextField(propRefNoParam);
+ add(propRefNo);
+ }
+
+ /**
+ * Initialize Form values from Contact object.
+ */
+ public void init(FormSectionEvent fse) {
+
+ FormData data = fse.getFormData();
+ Contact contact = (Contact) this.getItemSelectionModel().getSelectedObject(fse.getPageState());
+ ContactAddress ctAddress = contact.getContactAddress();
+
+ if(ctAddress != null){
+
+ data.put(ContactAddress.PAON, ctAddress.getPaon());
+ data.put(ContactAddress.SAON, ctAddress.getSaon());
+ data.put(ContactAddress.STREET_DESC, ctAddress.getStreetDesc());
+ data.put(ContactAddress.STREET_REF_NO, ctAddress.getStreetRefNo());
+ data.put(ContactAddress.LOCALITY, ctAddress.getLocality());
+ data.put(ContactAddress.TOWN, ctAddress.getTown());
+ data.put(ContactAddress.ADMINISTRATIVE_AREA, ctAddress.getAdministrativeArea());
+ data.put(ContactAddress.POST_TOWN, ctAddress.getPostTown());
+ data.put(ContactAddress.POST_CODE, ctAddress.getPostCode());
+ data.put(ContactAddress.PROP_REF_NO, ctAddress.getReferenceNo());
+
+ }
+ }
+
+ /**
+ * Process the form submission event.
+ * Create a new ContactAddress object and associate it with
+ * Contact object if one does not exist yet.
+ */
+ public void process(FormSectionEvent fse) {
+
+ FormData data = fse.getFormData();
+ Contact contact = (Contact) this.getItemSelectionModel().getSelectedObject(fse.getPageState());
+ s_log.debug("Process Event Object :" + contact);
+
+ // save only if save button was pressed
+ if (contact != null
+ && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
+
+ ContactAddress ctAddress = contact.getContactAddress();
+ //User submitted the Form.If the associated ContactAddress does not exist
+ //just create it.
+ if(ctAddress == null){
+ ctAddress = new ContactAddress();
+ ctAddress.setName("address-for-contact-"+ contact.getID());
+ }
+
+ ctAddress.setPaon((String) data.get(ContactAddress.PAON));
+ ctAddress.setSaon((String) data.get(ContactAddress.SAON));
+ ctAddress.setStreetDesc((String) data.get(ContactAddress.STREET_DESC));
+ ctAddress.setStreetRefNo((String) data.get(ContactAddress.STREET_REF_NO));
+
+ ctAddress.setLocality((String) data.get(ContactAddress.LOCALITY));
+ ctAddress.setTown((String) data.get(ContactAddress.TOWN));
+ ctAddress.setAdministrativeArea((String) data.get(ContactAddress.ADMINISTRATIVE_AREA));
+ ctAddress.setPostTown((String) data.get(ContactAddress.POST_TOWN));
+ ctAddress.setPostCode((String) data.get(ContactAddress.POST_CODE));
+ ctAddress.setReferenceNo((String) data.get(ContactAddress.PROP_REF_NO));
+
+ ctAddress.save();
+
+ //If not present then only set and save Contact object.
+ if(contact.getContactAddress() == null){
+ contact.setContactAddress(ctAddress);
+ contact.save();
+ }
+ }
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactCreate.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactCreate.java
new file mode 100755
index 000000000..8f86140a9
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactCreate.java
@@ -0,0 +1,99 @@
+/*
+ * 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.ui.contact;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
+import com.arsdigita.cms.ContentBundle;
+import com.arsdigita.cms.ContentSection;
+import com.arsdigita.cms.Folder;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.CreationSelector;
+import com.arsdigita.cms.ui.authoring.PageCreate;
+
+/**
+ * Authoring kit create component to create objects of Contact
+ * ContentType objects.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: ContactCreate.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class ContactCreate extends PageCreate {
+
+ private CreationSelector m_parent;
+
+ public ContactCreate(ItemSelectionModel itemModel,
+ CreationSelector parent) {
+
+ super(itemModel, parent);
+ m_parent = parent;
+ }
+
+ protected void addWidgets () {
+
+ super.addWidgets();
+
+ TextField givenName = new TextField(Contact.GIVEN_NAME);
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_givenname")));
+ givenName.addValidationListener(new NotNullValidationListener());
+ add(givenName);
+
+ TextField familyName = new TextField(Contact.FAMILY_NAME);
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_familyname")));
+ familyName.addValidationListener(new NotNullValidationListener());
+ add(familyName);
+ }
+
+ public void process ( FormSectionEvent e ) throws FormProcessException{
+
+ FormData data = e.getFormData();
+ PageState state = e.getPageState();
+
+ // try to get the contact section from the state parameter
+ Folder f = m_parent.getFolder(state);
+ ContentSection sec = m_parent.getContentSection(state);
+ Contact contact = (Contact) createContentPage(state);
+ contact.setLanguage((String) data.get(LANGUAGE));
+ contact.setName((String)data.get(NAME));
+ contact.setTitle((String)data.get(TITLE));
+ contact.setGivenName((String)data.get(Contact.GIVEN_NAME));
+ contact.setFamilyName((String)data.get(Contact.FAMILY_NAME));
+ contact.save();
+
+ final ContentBundle bundle = new ContentBundle(contact);
+ bundle.setParent(f);
+ bundle.setContentSection(m_parent.getContentSection(state));
+ bundle.save();
+
+ // aplaws default workflow
+ getWorkflowSection().applyWorkflow(state, contact);
+
+ m_parent.editItem(state, contact);
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactPropertiesStep.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactPropertiesStep.java
new file mode 100755
index 000000000..3953a607f
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactPropertiesStep.java
@@ -0,0 +1,134 @@
+/*
+ * 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.ui.contact;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.authoring.BasicPageForm;
+import com.arsdigita.cms.ui.authoring.SimpleEditStep;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+import com.arsdigita.cms.util.GlobalizationUtil;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
+import com.arsdigita.bebop.PageState;
+
+/**
+ * Authoring kit step to view/edit basic properties of Contact object.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: ContactPropertiesStep.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class ContactPropertiesStep extends SimpleEditStep {
+
+ /** The name of the editing sheet added to this step */
+ public static String EDIT_SHEET_NAME = "edit";
+
+ public ContactPropertiesStep(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent) {
+ super(itemModel, parent);
+
+ BasicPageForm editSheet;
+
+ editSheet = new ContactPropertyForm(itemModel);
+ add(
+ EDIT_SHEET_NAME,
+ "Edit",
+ new WorkflowLockedComponentAccess(editSheet, itemModel),
+ editSheet.getSaveCancelSection().getCancelButton());
+
+ setDisplayComponent(getContactPropertySheet(itemModel));
+ }
+
+ /**
+ * Returns a component that displays the properties of the Contact specified
+ * by the ItemSelectionModel passed in.
+ *
+ * @param itemModel
+ * The ItemSelectionModel to use @pre itemModel != null
+ * @return A component to display the state of the basic properties of the
+ */
+ public static Component getContactPropertySheet(ItemSelectionModel itemModel) {
+ DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
+
+ sheet.add(
+ GlobalizationUtil.globalize("cms.contenttypes.ui.name"),
+ Contact.NAME);
+
+ sheet.add(
+ GlobalizationUtil.globalize("cms.contenttypes.ui.title"),
+ Contact.TITLE);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize(
+ "cms.contenttypes.ui.contact_givenname"),
+ Contact.GIVEN_NAME);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize(
+ "cms.contenttypes.ui.contact_familyname"),
+ Contact.FAMILY_NAME);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_type"),
+ Contact.CONTACT_TYPE,
+ new DomainObjectPropertySheet.AttributeFormatter() {
+ public String format(DomainObject item,String attribute,PageState state) {
+ Contact contact = (Contact) item;
+ if (contact.getContactType() != null) {
+ return contact.getContactTypeName();
+ } else {
+ return "unknown";
+ }
+ }
+ });
+
+ sheet.add(
+ GlobalizationUtil.globalize("cms.contenttypes.ui.description"),
+ Contact.DESCRIPTION);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_emails"),
+ Contact.EMAILS);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_suffix"),
+ Contact.SUFFIX);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_orgname"),
+ Contact.ORG_NAME);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize(
+ "cms.contenttypes.ui.contact_deptname"),
+ Contact.DEPT_NAME);
+
+ sheet.add(
+ ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_role"),
+ Contact.ROLE);
+
+ return sheet;
+ }
+
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactPropertyForm.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactPropertyForm.java
new file mode 100755
index 000000000..51cbdc538
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/ContactPropertyForm.java
@@ -0,0 +1,205 @@
+/*
+ * 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.ui.contact;
+
+import java.math.BigDecimal;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.form.Option;
+import com.arsdigita.bebop.form.SingleSelect;
+import com.arsdigita.bebop.form.TextArea;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.ParameterModel;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.ContactType;
+import com.arsdigita.cms.contenttypes.ContactTypesCollection;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.BasicPageForm;
+
+/**
+ * Form to edit basic properties of Contact object. Used by
+ * ContactPropertiesStep authoring kit step.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactPropertyForm.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactPropertyForm extends BasicPageForm {
+
+ /** Name of this form */
+ public static final String ID = "Contact_edit";
+
+ /**
+ * Creates a new form to edit the Contact object specified by the item
+ * selection model passed in.
+ *
+ * @param itemModel
+ * The ItemSelectionModel to use to obtain the Contact to work on
+ */
+ public ContactPropertyForm(ItemSelectionModel itemModel) {
+ super(ID, itemModel);
+ }
+
+ /**
+ * Adds widgets to the form. This has been cut into small methods
+ * so that subclasses can pick and choose.
+ */
+ protected void addWidgets() {
+ addBasicPageFormWidgets();
+ addGivenNameWidget();
+ addFamilyNameWidget();
+ addSuffixWidget();
+ addContactTypeWidget();
+ addDescriptionWidget();
+ addEmailsWidget();
+ addOrganizationNameWidget();
+ addDepartmentNameWidget();
+ addRoleWidget();
+ }
+
+ protected void addBasicPageFormWidgets() {
+ super.addWidgets();
+ }
+
+ protected void addGivenNameWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_givenname")));
+ ParameterModel givenNameParam = new StringParameter(Contact.GIVEN_NAME);
+ TextField givenName = new TextField(givenNameParam);
+ add(givenName);
+ }
+
+ protected void addFamilyNameWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_familyname")));
+ ParameterModel familyNameParam = new StringParameter(Contact.FAMILY_NAME);
+ TextField familyName = new TextField(familyNameParam);
+ add(familyName);
+ }
+
+ protected void addSuffixWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_suffix")));
+ ParameterModel suffixParam = new StringParameter(Contact.SUFFIX);
+ TextField suffix = new TextField(suffixParam);
+ add(suffix);
+ }
+
+ protected void addContactTypeWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_type")));
+ ParameterModel contactTypeParam = new StringParameter(Contact.CONTACT_TYPE);
+ SingleSelect contactType = new SingleSelect(contactTypeParam);
+ add(contactType);
+ // retrieve Contact types
+ ContactTypesCollection ctTypes = ContactTypesCollection.getContactTypesCollection();
+ while (ctTypes.next()) {
+ contactType.addOption(new Option(ctTypes.getContactTypeID().toString(), ctTypes.getContactTypeName()));
+ }
+ }
+
+ protected void addDescriptionWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_description")));
+ ParameterModel descParam = new StringParameter(Contact.DESCRIPTION);
+ TextArea desc = new TextArea(descParam);
+ desc.setRows(5);
+ add(desc);
+ }
+
+ protected void addEmailsWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_emails")));
+ ParameterModel emailsParam = new StringParameter(Contact.EMAILS);
+ TextField emails = new TextField(emailsParam);
+ add(emails);
+ }
+
+ protected void addOrganizationNameWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_orgname")));
+ ParameterModel orgNameParam = new StringParameter(Contact.ORG_NAME);
+ TextField orgName = new TextField(orgNameParam);
+ add(orgName);
+ }
+
+ protected void addDepartmentNameWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_deptname")));
+ ParameterModel deptParam = new StringParameter(Contact.DEPT_NAME);
+ TextField deptName = new TextField(deptParam);
+ add(deptName);
+ }
+
+ protected void addRoleWidget() {
+ add(new Label(ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_role")));
+ ParameterModel roleParam = new StringParameter(Contact.ROLE);
+ TextField role = new TextField(roleParam);
+ add(role);
+ }
+
+ /**
+ * Initialize Form values from Contact object.
+ */
+ public void init(FormSectionEvent fse) {
+
+ FormData data = fse.getFormData();
+ Contact contact = (Contact) super.initBasicWidgets(fse);
+
+ if (contact.getContactType() != null) {
+ data.put(Contact.CONTACT_TYPE, contact.getContactType().getID());
+ }
+
+ data.put(Contact.GIVEN_NAME, contact.getGivenName());
+ data.put(Contact.FAMILY_NAME, contact.getFamilyName());
+ data.put(Contact.SUFFIX, contact.getSuffix());
+ data.put(Contact.EMAILS, contact.getEmails());
+ data.put(Contact.DESCRIPTION, contact.getDescription());
+ data.put(Contact.ORG_NAME, contact.getOrganisationName());
+ data.put(Contact.DEPT_NAME, contact.getDeptName());
+ data.put(Contact.ROLE, contact.getRole());
+ }
+
+ /**
+ * Process the form submission event.
+ */
+ public void process(FormSectionEvent fse) {
+
+ FormData data = fse.getFormData();
+ Contact contact = (Contact) super.processBasicWidgets(fse);
+
+ // save only if save button was pressed
+ if (contact != null
+ && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
+
+ contact.setGivenName((String) data.get(Contact.GIVEN_NAME));
+ contact.setFamilyName((String) data.get(Contact.FAMILY_NAME));
+ contact.setSuffix((String) data.get(Contact.SUFFIX));
+ contact.setEmails((String) data.get(Contact.EMAILS));
+ String contactTypeIDStr = (String) data.get(Contact.CONTACT_TYPE);
+ if (contactTypeIDStr != null) {
+ BigDecimal contactTypeID =
+ new BigDecimal(contactTypeIDStr);
+ ContactType ctType = new ContactType(contactTypeID);
+ contact.setContactType(ctType);
+ }
+
+ contact.setDescription((String) data.get(Contact.DESCRIPTION));
+ contact.setOrganisationName((String) data.get(Contact.ORG_NAME));
+ contact.setDeptName((String) data.get(Contact.DEPT_NAME));
+ contact.setRole((String) data.get(Contact.ROLE));
+ contact.save();
+ }
+ }
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/CreatePhone.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/CreatePhone.java
new file mode 100755
index 000000000..459519314
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/CreatePhone.java
@@ -0,0 +1,121 @@
+/*
+ * 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.ui.contact;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.form.Option;
+import com.arsdigita.bebop.form.SingleSelect;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
+import com.arsdigita.bebop.parameters.ParameterModel;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.ContactInitializer;
+import com.arsdigita.cms.contenttypes.ContactPhone;
+import com.arsdigita.cms.contenttypes.util.ContactGlobalizationUtil;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+
+import java.util.ArrayList;
+
+/**
+ * Form to Create objects of type ContactPhone.
+ *
+ * @author Shashin Shinde
+ *
+ * @version $Id: CreatePhone.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+class CreatePhone extends BasicItemForm {
+
+ private ItemSelectionModel m_model;
+
+ /**
+ * Creates a new form to create the ContactPhone object
+ * type associated with the Contact object specified
+ * by the item selection model passed in.
+ *
+ * @param itemModel
+ * The ItemSelectionModel to use to obtain the Contact object to
+ * work on
+ */
+ public CreatePhone(ItemSelectionModel itemModel) {
+ super("Contact_phone_create", itemModel);
+ m_model = itemModel;
+ }
+
+ /**
+ * Adds widgets to edit the address properties to form. Only paon and
+ * streetDesc are required, rest are optional.
+ */
+ protected void addWidgets() {
+
+ add(new Label(ContactGlobalizationUtil.globalize(
+ "cms.contenttypes.ui.contact.phone_number")));
+ ParameterModel phoneNoParam = new StringParameter(ContactPhone.PHONE_NUMBER);
+ TextField phoneNo = new TextField(phoneNoParam);
+ phoneNo.addValidationListener(new NotNullValidationListener());
+ add(phoneNo);
+
+ add(new Label(ContactGlobalizationUtil.globalize(
+ "cms.contenttypes.ui.phone_type")));
+ ParameterModel phoneTypeParam = new StringParameter(ContactPhone.PHONE_TYPE);
+ SingleSelect phoneType = new SingleSelect(phoneTypeParam);
+ add(phoneType);
+ // retrieve static Phone types
+ ArrayList phTypes = ContactInitializer.getPhoneTypes();
+ for (int i = 0; i < phTypes.size(); i++) {
+ phoneType.addOption(
+ new Option(phTypes.get(i).toString(), phTypes.get(i).toString()));
+ }
+ }
+
+ /**
+ */
+ public void init(FormSectionEvent e) {
+ //Do nothing.
+ }
+
+ /**
+ * Create an object of type ContactPhone and add it to Contact
+ * object retrieved from passed in ItemSelectionModel.
+ */
+ public void process(FormSectionEvent fse) {
+ FormData data = fse.getFormData();
+ Contact contact = (Contact) m_model.getSelectedObject(fse.getPageState());
+
+ // save only if save button was pressed
+ if (contact != null
+ && getSaveCancelSection().getSaveButton().isSelected(
+ fse.getPageState())) {
+
+ ContactPhone cph = new ContactPhone();
+ cph.setName("phone-for-contact-" + contact.getID());
+
+ cph.setPhoneType((String) data.get(ContactPhone.PHONE_TYPE));
+ cph.setPhoneNumber((String) data.get(ContactPhone.PHONE_NUMBER));
+ cph.save();
+
+ //Add it to the contact.
+ contact.addPhone(cph);
+ }
+ }
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/PhonesPanel.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/PhonesPanel.java
new file mode 100755
index 000000000..4dd972f83
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/PhonesPanel.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ui.contact;
+
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.cms.ui.authoring.SimpleEditStep;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+
+/**
+ * A UI step to manipulate Phones for the Contact object
+ * which is retrieved from the ItemSelectionModel.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: PhonesPanel.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+public class PhonesPanel extends SimpleEditStep {
+
+ /** The name of the editing sheet added to this step */
+ private static String EDIT_SHEET_NAME = "manage-phones";
+
+ public PhonesPanel(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
+ super(itemModel, parent);
+
+ BasicItemForm form = new CreatePhone(itemModel);
+
+ add(
+ EDIT_SHEET_NAME,
+ "Add Phone",
+ new WorkflowLockedComponentAccess(form, itemModel),
+ form.getSaveCancelSection().getCancelButton());
+
+ PhonesTable phTable = new PhonesTable(itemModel);
+ setDisplayComponent(phTable);
+
+ }
+
+}
\ No newline at end of file
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/PhonesTable.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/PhonesTable.java
new file mode 100755
index 000000000..d9c0db3ea
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ui/contact/PhonesTable.java
@@ -0,0 +1,211 @@
+/*
+ * 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.ui.contact;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.bebop.ControlLink;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.Table;
+import com.arsdigita.bebop.event.TableActionEvent;
+import com.arsdigita.bebop.event.TableActionListener;
+import com.arsdigita.bebop.table.TableCellRenderer;
+import com.arsdigita.bebop.table.TableColumn;
+import com.arsdigita.bebop.table.TableColumnModel;
+import com.arsdigita.bebop.table.TableModel;
+import com.arsdigita.bebop.table.TableModelBuilder;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.SecurityManager;
+import com.arsdigita.cms.contenttypes.Contact;
+import com.arsdigita.cms.contenttypes.ContactPhone;
+import com.arsdigita.cms.contenttypes.PhonesCollection;
+import com.arsdigita.cms.dispatcher.Utilities;
+import com.arsdigita.util.LockableImpl;
+
+import java.math.BigDecimal;
+
+/**
+ * A Table to display the Phones associated with the Contact object.
+ * Provides links to delete the corresponding phone in each row.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ *
+ * @version $Id: PhonesTable.java 287 2005-02-22 00:29:02Z sskracic $
+ *
+ */
+class PhonesTable extends Table implements TableActionListener{
+
+ private ItemSelectionModel m_contactSel;
+
+ private static final String COL_PHONE_TYPE ="Phone Type";
+ private static final String COL_PHONE_NUM="Phone Number";
+ private static final String COL_DELETE ="Delete";
+
+ /**
+ * Constructor.Create an instance of this class.
+ *
+ * @param selContact , ItemSelectionModel which provides the
+ * Contact object whose Phones are to be manipulated.
+ */
+ public PhonesTable(ItemSelectionModel selContact) {
+ super();
+ m_contactSel = selContact;
+
+ setEmptyView(new Label("No Phones associated with this Contact"));
+
+ TableColumnModel model = getColumnModel();
+ model.add( new TableColumn( 0, COL_PHONE_TYPE ));
+ model.add( new TableColumn( 1, COL_PHONE_NUM ));
+ model.add( new TableColumn( 2, COL_DELETE ));
+
+ setModelBuilder(new PhonesTableModelBuilder(selContact));
+
+ model.get(2).setCellRenderer(new DeleteCellRenderer());
+
+ addTableActionListener(this);
+
+ }
+
+ private class PhonesTableModelBuilder extends LockableImpl implements TableModelBuilder {
+
+ private ItemSelectionModel m_sel;
+
+ private PhonesTableModelBuilder(ItemSelectionModel sel){
+ m_sel = sel;
+ }
+
+ public TableModel makeModel ( Table table, PageState state ) {
+ table.getRowSelectionModel().clearSelection(state);
+
+ Contact contact = (Contact) m_sel.getSelectedObject(state);
+
+ return new PhonesTableModel(table, state, contact);
+ }
+ }
+
+ private class PhonesTableModel implements TableModel{
+
+ private Table m_table;
+ private PhonesCollection m_phones;
+ private ContactPhone m_phone;
+
+ private PhonesTableModel(Table t,PageState ps,Contact c){
+ m_table = t;
+ m_phones = c.getPhones();
+ }
+
+ public int getColumnCount() {
+ return m_table.getColumnModel().size();
+ }
+
+ /**
+ * check collection for the existence of another row.If it has fetch the
+ * value of Current Phone object into m_phone class variable.
+ */
+ public boolean nextRow() {
+ if(m_phones != null && m_phones.next()){
+ m_phone = m_phones.getPhone();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Return the phoneType and phoneNumber attributes for the Type and
+ * Number columns respectively.
+ * @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
+ */
+ public Object getElementAt(int columnIndex) {
+ switch (columnIndex){
+ case 0:
+ return m_phone.getPhoneType();
+ case 1:
+ return m_phone.getPhoneNumber();
+ case 2:
+ return "Delete";
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Always return the ID of Phone represented by current row.
+ * @see com.arsdigita.bebop.table.TableModel#getKeyAt(int)
+ */
+ public Object getKeyAt(int columnIndex) {
+ return m_phone.getID();
+ }
+
+ }
+
+ /**
+ * Check for the permissions to delete item and put either a Lable or
+ * a ControlLink accordingly.
+ */
+ private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer{
+
+ public Component getComponent(Table table,PageState state,Object value,
+ boolean isSelected,Object key,
+ int row,int column) {
+
+
+ SecurityManager sm = Utilities.getSecurityManager(state);
+ Contact item = (Contact) m_contactSel.getSelectedObject(state);
+
+ boolean canDelete = sm.canAccess(state.getRequest(),
+ SecurityManager.DELETE_ITEM,
+ item);
+ if ( canDelete) {
+ ControlLink link = new ControlLink(value.toString());
+ link.setConfirmation("Delete this Phone ?");
+ return link;
+ } else {
+ return new Label(value.toString());
+ }
+ }
+}
+
+ /**
+ * Provide implementation to TableActionListener method.
+ * Code that comes into picture when a link on the table is clicked.
+ * Handles delete event.
+ */
+ public void cellSelected(TableActionEvent evt) {
+ PageState state = evt.getPageState();
+
+ TableColumn col = getColumnModel().get(evt.getColumn().intValue());
+ String colName = (String) col.getHeaderValue();
+
+ if ( COL_DELETE.equals(colName) ) {
+ BigDecimal phoneID = new BigDecimal(evt.getRowKey().toString());
+ Contact contact = (Contact) m_contactSel.getSelectedObject(state);
+ ContactPhone ph = new ContactPhone(phoneID);
+ contact.removePhone(ph);
+ }
+ }
+
+ /**
+ * provide Implementation to TableActionListener method.
+ * Does nothing in our case.
+ */
+ public void headSelected(TableActionEvent e) {
+ throw new UnsupportedOperationException("Not Implemented");
+ }
+}
diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/util/ContactGlobalizationUtil.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/util/ContactGlobalizationUtil.java
new file mode 100755
index 000000000..f96e60ab6
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/util/ContactGlobalizationUtil.java
@@ -0,0 +1,52 @@
+/*
+ * 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.util;
+
+import com.arsdigita.globalization.GlobalizedMessage;
+
+/**
+ *
+ * Contains methods to simplify globalizing keys related to Contact
+ * ContentType object.
+ *
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactGlobalizationUtil.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactGlobalizationUtil {
+
+ final public static String BUNDLE_NAME =
+ "com.arsdigita.cms.contenttypes.util.ContactResourceBundle";
+
+ /**
+ * 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-ldn-types-contact/src/com/arsdigita/cms/contenttypes/util/ContactResourceBundle.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/util/ContactResourceBundle.java
new file mode 100755
index 000000000..52cb76711
--- /dev/null
+++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/util/ContactResourceBundle.java
@@ -0,0 +1,44 @@
+/*
+ * 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.util;
+
+import java.util.PropertyResourceBundle;
+
+import com.arsdigita.globalization.ChainedResourceBundle;
+
+import com.arsdigita.cms.CMSGlobalized;
+
+/**
+ * Resource Bundle used in UI for Contact ContentType.
+ *
+ * @author Shashin Shinde sshinde@redhat.com
+ * @version $Id: ContactResourceBundle.java 287 2005-02-22 00:29:02Z sskracic $
+ */
+public class ContactResourceBundle extends ChainedResourceBundle implements CMSGlobalized {
+
+ public final static String CONTACT_BUNDLE_NAME =
+ "com.arsdigita.cms.contenttypes.ContactResources";
+
+ public ContactResourceBundle() {
+ super();
+ addBundle((PropertyResourceBundle)getBundle(CONTACT_BUNDLE_NAME));
+ addBundle((PropertyResourceBundle)getBundle(BUNDLE_NAME));
+ }
+
+}
diff --git a/ccm-ldn-types-contact/web/static/content-types/com/arsdigita/cms/contenttypes/Contact.xsl b/ccm-ldn-types-contact/web/static/content-types/com/arsdigita/cms/contenttypes/Contact.xsl
new file mode 100755
index 000000000..bb33a8ab5
--- /dev/null
+++ b/ccm-ldn-types-contact/web/static/content-types/com/arsdigita/cms/contenttypes/Contact.xsl
@@ -0,0 +1,153 @@
+
+]>
+
+
+
+
+
+
+
+ Contact Address Details
+ Contact Phones
+
+
+
+
+
+ Given Name:
+
+
+
+ Family Name:
+
+
+
+ Contact Type:
+
+
+
+ Description:
+
+
+
+
+ Contact Emails:
+
+
+
+ Suffix:
+
+
+
+ Organisation Name:
+
+
+
+ Department Name:
+
+
+
+ Role:
+
+
+
+
+
+
+
+ SAON:
+
+
+
+
+ PAON:
+
+
+
+
+ Street Description:
+
+
+
+
+ Locality:
+
+
+
+
+ Town:
+
+
+
+
+ Postal Code:
+
+
+
+
+ Postal Town:
+
+
+
+
+ Administrative Area:
+
+
+
+
+
+
+
+
+ Phone Type
+ Phone Number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CONTACT& gt;
+ Given Name
+
+ Family Name
+
+ Contact Suffix
+
+ Contact Type
+
+ Description
+
+ Organisation Name
+
+ Department Name
+
+ Role
+
+
+
+
+
+ Contact Phone Type
+
+ Contact Phone Number
+
+
+
+