diff --git a/ccm-cms-types-healthCareFacility/application.xml b/ccm-cms-types-healthCareFacility/application.xml new file mode 100644 index 000000000..b58f39a82 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/application.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + This is a collection of content types for managing / storing / rating health care organizations. + + diff --git a/ccm-cms-types-healthCareFacility/pdl/com/arsdigita/content-types/HealthCareFacility.pdl b/ccm-cms-types-healthCareFacility/pdl/com/arsdigita/content-types/HealthCareFacility.pdl new file mode 100644 index 000000000..427696f1d --- /dev/null +++ b/ccm-cms-types-healthCareFacility/pdl/com/arsdigita/content-types/HealthCareFacility.pdl @@ -0,0 +1,36 @@ +model com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.contenttypes.GenricOrganization; +import com.arsdigita.cms.contenttypes.BaseAddress; +import com.arsdigita.cms.contenttypes.BaseContact; +//import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.cms.*; + +// HealthCareFacility Object +object type HealthCareFacility extends GenericOrganization { + + BaseAddress[0..1] address = join ct_healthCareFacilities.address_id + to ct_baseAddresses.address_id; + + reference key ( ct_healthCareFacilities.hcf_id ); +} + +association { + + BaseContact[0..n] contacts = join ct_healthCareFacilities.hcf_id + to ct_healthCareFacility_baseContact_map.hcf_id, + join ct_healthCareFacility_baseContact_map.contact_id + to ct_baseContacts.contact_id; + + HealthCareFacility[0..n] healthCareFacilities = join ct_baseContacts.contact_id + to ct_healthCareFacility_baseContact_map.contact_id, + join ct_healthCareFacility_baseContact_map.hcf_id + to ct_healthCareFacilities.hcf_id; + + // Link Attribute + String contact_type = ct_healthCareFacility_baseContact_map.contact_type VARCHAR(100); + BigDecimal contact_order = ct_healthCareFacility_baseContact_map.contact_order INTEGER; + +} + diff --git a/ccm-cms-types-healthCareFacility/sql/ccm-cms-types-healthCareFacility/oracle-se-create.sql b/ccm-cms-types-healthCareFacility/sql/ccm-cms-types-healthCareFacility/oracle-se-create.sql new file mode 100644 index 000000000..733784c1c --- /dev/null +++ b/ccm-cms-types-healthCareFacility/sql/ccm-cms-types-healthCareFacility/oracle-se-create.sql @@ -0,0 +1,22 @@ +-- +-- Copyright (C) 2003-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 +-- +-- $Id: oracle-se-create.sql 287 2005-02-22 00:29:02Z sskracic $ +-- $DateTime: 2004/08/17 23:15:09 $ +@ ddl/oracle-se/create.sql + +@ ddl/oracle-se/deferred.sql diff --git a/ccm-cms-types-healthCareFacility/sql/ccm-cms-types-healthCareFacility/postgres-create.sql b/ccm-cms-types-healthCareFacility/sql/ccm-cms-types-healthCareFacility/postgres-create.sql new file mode 100644 index 000000000..7ea108389 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/sql/ccm-cms-types-healthCareFacility/postgres-create.sql @@ -0,0 +1,23 @@ +-- +-- Copyright (C) 2003-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 +-- +-- $Id: postgres-create.sql 287 2005-02-22 00:29:02Z sskracic $ +-- $DateTime: 2004/08/17 23:15:09 $ +begin; +\i ddl/postgres/create.sql +\i ddl/postgres/deferred.sql +end; diff --git a/ccm-cms-types-healthCareFacility/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xml b/ccm-cms-types-healthCareFacility/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xml new file mode 100644 index 000000000..8edfc601f --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/ccm-cms-types-healthCareFacility/src/ccm-cms-types-healthCareFacility.config b/ccm-cms-types-healthCareFacility/src/ccm-cms-types-healthCareFacility.config new file mode 100644 index 000000000..000bb7c1b --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/ccm-cms-types-healthCareFacility.config @@ -0,0 +1,4 @@ + + + + diff --git a/ccm-cms-types-healthCareFacility/src/ccm-cms-types-healthCareFacility.load b/ccm-cms-types-healthCareFacility/src/ccm-cms-types-healthCareFacility.load new file mode 100644 index 000000000..e700206f2 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/ccm-cms-types-healthCareFacility.load @@ -0,0 +1,20 @@ + + + +
+
+
+
+
+ + + +
+ + + + + + + + diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/BaseContactCollection.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/BaseContactCollection.java new file mode 100644 index 000000000..4d1565e9d --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/BaseContactCollection.java @@ -0,0 +1,65 @@ +/* + * BaseContactCollection.java + * + * Created on 26. Juli 2009, 15:30 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.persistence.DataCollection; +import java.math.BigDecimal; + +/** + * + * @author quasi + */ +public class BaseContactCollection extends DomainCollection { + + public static final String ORDER = "link.contact_order asc"; + public static final String CONTACT_TYPE = "link.contact_type"; + public static final String CONTACT_ORDER = "link.contact_order"; + + /** + * Creates a new instance of BaseContactCollection + */ + public BaseContactCollection(DataCollection dataCollection) { + super(dataCollection); + + m_dataCollection.addOrder(ORDER); + } + + // Get the contact type of the link + public String getContactType() { + return (String) m_dataCollection.get(CONTACT_TYPE); + } + + // Set the contact type of the link +// public void setContactType(String contactType) { +// getBaseContact().set(CONTACT_TYPE, contactType); +// } + + // Get the contact order of the link + public String getContactOrder() { + String retVal = ((BigDecimal) m_dataCollection.get(CONTACT_ORDER)).toString(); + + if(retVal == null || retVal.isEmpty()) { + retVal = String.valueOf(this.getPosition()); + } + + return retVal; + } + + // Set the contact order of the link +// public void setContactOrder(long contactOrder) { +// getBaseContact().set(CONTACT_ORDER, String.valueOf(contactOrder)); +// } + + public BaseContact getBaseContact() { + return new BaseContact(m_dataCollection.getDataObject()); + } + +} diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java new file mode 100644 index 000000000..27d0f22b0 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2009 Sören Bernstein, for the Center of Social Politics of the University of Bremen + * + * 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.DataObjectNotFoundException; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.OID; +import com.arsdigita.util.Assert; +import java.math.BigDecimal; + +import org.apache.log4j.Logger; + +/** + * This represents an organization. It is designed to be suitable + * for most organizations. Currently, it offers the following properties: + * - name of the organization + * - an addendum for the name + * - a short description of the organization. + * + * It is also possible to add roles to the organization, e.g. CEO, mayor or others. + * The following features are planned to implement in one of the next commits: + * - Adding OrganizationUnits + * + * The current version of this contenttype is modeled on base of the MultipartArticle + * contenttype. + * + * @author Sören Bernstein + */ +public class HealthCareFacility extends GenericOrganization { + + //private static final HealthCareFacilityConfig s_config = new HealthCareFacilityConfig(); + private static final Logger s_log = Logger.getLogger(HealthCareFacility.class); + + private static final HealthCareFacilityConfig s_config = new HealthCareFacilityConfig(); + + public static final String ADDRESS = "address"; + public static final String CONTACTS = "contacts"; + public static final String CONTACT_TYPE = "contact_type"; + public static final String CONTACT_ORDER = "contact_order"; + + public static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.HealthCareFacility"; + + /** + * Called when the class is loaded by the Java class loader. + */ + static { + s_config.load(); + } + + /** + * Returns a possibly existing configuration object for the class. + * + * @return config object + */ + public static final HealthCareFacilityConfig getConfig() { + return s_config; + } + + /** + * Default constructor. This creates a new (empty) health care facility + */ + public HealthCareFacility() { + this(BASE_DATA_OBJECT_TYPE); + } + + /** + * Trys to find an health care facility in the database by its id. + * + * @param id ID of the object to (re-)create + * @throws DataObjectNotFoundException if no object with the given id is found in the database. + */ + public HealthCareFacility(BigDecimal id) throws DataObjectNotFoundException { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); + } + + /** + * Trys to find an health care facility in the database by its OID. + * + * @param id ID of the object to (re-)create + * @throws DataObjectNotFoundException if no object with the given OID is found in the database. + */ + public HealthCareFacility(OID id) throws DataObjectNotFoundException { + super(id); + } + + /** + * Create an new HealthCareFacility object from a DataObject + * + * @param obj The data object + */ + public HealthCareFacility(DataObject obj) { + super(obj); + } + + /** + * Not sure for what this constructor is. + * + * @param type The type of the object to create (?) + */ + public HealthCareFacility(String type) { + super(type); + } + + + /* accessors *************************************************/ + + // Get the address for this contact + public BaseAddress getAddress() { + return (BaseAddress)DomainObjectFactory.newInstance((DataObject)get(ADDRESS)); + } + + // Set the address for this contact + public void setAddress(BaseAddress address) { + set(ADDRESS, address); + } + + // Unset the address for this contact + public void unsetAddress() { + set(ADDRESS, null); + } + + // Get all contacts for this health care facility + public BaseContactCollection getContacts() { + return new BaseContactCollection((DataCollection) get(CONTACTS)); + } + + // Add a contact for this health care facility + public void addContact(BaseContact contact, String contactType) { + Assert.exists(contact, BaseContact.class); + + DataObject link = add(CONTACTS, contact); + + link.set(CONTACT_TYPE, contactType); + link.set(CONTACT_ORDER, BigDecimal.valueOf(getContacts().size())); +// this.save(); + +// add(CONTACTS, contact); + } + + // Remove a contect for this health care facility + public void removeContactEntry(BaseContact contact) { + Assert.exists(contact, BaseContact.class); + remove(CONTACTS, contact); + } + + public boolean hasContacts() { + return !this.getContacts().isEmpty(); + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityConfig.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityConfig.java new file mode 100644 index 000000000..58cc4831a --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityConfig.java @@ -0,0 +1,133 @@ + +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.runtime.AbstractConfig; +import com.arsdigita.util.parameter.Parameter; +import com.arsdigita.util.parameter.BooleanParameter; +import com.arsdigita.util.parameter.StringParameter; +import java.util.StringTokenizer; +import org.apache.log4j.Logger; + +/** + * Stores the configuration record for the healthCareFacility. + * + * @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de + */ +public final class HealthCareFacilityConfig extends AbstractConfig { + + private static Logger s_log = Logger.getLogger(HealthCareFacilityConfig.class); + + private final Parameter m_hideAddress; + private final Parameter m_hideAddressPostalCode; + private final Parameter m_hideAddressState; + private final Parameter m_hideAddressCountry; + private final Parameter m_contactTypeKeys; + + /** + * Public Constructor + */ + public HealthCareFacilityConfig() { + + /** + * If set to true disables the possibility to attach a baseAddress ct + */ + m_hideAddress = new BooleanParameter + ("com.arsdigita.cms.contenttypes.healthCareFacility.hide_address", + Parameter.REQUIRED, + new Boolean(false)); + + /** + * If set to true hides the postal code entry field for the attached address ct + */ + m_hideAddressPostalCode = new BooleanParameter + ("com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_postal_code", + Parameter.REQUIRED, + new Boolean(false)); + + /** + * If set to true hides the state entry field for the attached address ct + */ + m_hideAddressState = new BooleanParameter + ("com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_state", + Parameter.REQUIRED, + new Boolean(false)); + + /** + * If set to true hides the country selection for the attaches address ct + */ + m_hideAddressCountry = new BooleanParameter + ("com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_country", + Parameter.REQUIRED, + new Boolean(false)); + + /** + */ + m_contactTypeKeys = new StringParameter + ("com.arsdigita.cms.contenttypes.healthCareFacility.contact_type_keys", + Parameter.REQUIRED, + "verwaltung,pflegeleitung,medLeitung"); + + register(m_hideAddress); + register(m_hideAddressPostalCode); + register(m_hideAddressState); + register(m_hideAddressCountry); + register(m_contactTypeKeys); + + loadInfo(); + } + + /** + */ + public final boolean getHideAddress() { + return ((Boolean) get(m_hideAddress)).booleanValue(); + } + + /** + */ + public final boolean getHideAddressPostalCode() { + return ((Boolean) get(m_hideAddressPostalCode)).booleanValue(); + } + + /** + */ + public final boolean getHideAddressState() { + return ((Boolean) get(m_hideAddressState)).booleanValue(); + } + + /** + */ + public final boolean getHideAddressCountry() { + return ((Boolean) get(m_hideAddressCountry)).booleanValue(); + } + + /** + * Returns the contactEntryKeys as StringTokenizer. + */ + public final StringTokenizer getContactTypeKeys() { + return new StringTokenizer((((String) get(m_contactTypeKeys)).replace(" ","")), ",", false); + } + + /** + * Return true, if language lang is part of supported langs + */ + public final boolean hasKey(String key) { + return ((String) get(m_contactTypeKeys)).contains(key); + } + + /** + * Return the index value for given key + */ + public final int getKeyIndex(String key) { + int index = -1; + + if(hasKey(key)) { + StringTokenizer keys = getContactTypeKeys(); + while(keys.hasMoreElements()) { + index++; + if(keys.nextToken().equals(key)) break; + } + } + + return index; + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityConfig_parameter.properties b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityConfig_parameter.properties new file mode 100644 index 000000000..b23835e62 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityConfig_parameter.properties @@ -0,0 +1,24 @@ +com.arsdigita.cms.contenttypes.healthCareFacility.hide_address.title=Hide address attachment +com.arsdigita.cms.contenttypes.healthCareFacility.hide_address.purpose=Hide the part to attach a baseAddress CT +com.arsdigita.cms.contenttypes.healthCareFacility.hide_address.example=false +com.arsdigita.cms.contenttypes.healthCareFacility.hide_address.format=[boolean] + +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_postal_code.title=Hide postal code for attached adress +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_postal_code.purpose=Hide the postal code entry field for the attached baseAddress +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_postal_code.example=false +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_postal_code.format=[boolean] + +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_state.title=Hide state for attached adress +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_state.purpose=Hide the state entry field for the attached baseAddress +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_state.example=false +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_state.format=[boolean] + +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_country.title=Hide country for attached address +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_country.purpose=Hide the country selection box for the attached baseAddress +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_country.example=false +com.arsdigita.cms.contenttypes.healthCareFacility.address.hide_country.format=[boolean] + +com.arsdigita.cms.contenttypes.healthCareFacility.contact_type_keys.title=Select available contact types +com.arsdigita.cms.contenttypes.healthCareFacility.contact_type_keys.purpose=Select available contact types and define display order +com.arsdigita.cms.contenttypes.healthCareFacility.contact_type_keys.example=verwaltung,pflegeleitung +com.arsdigita.cms.contenttypes.healthCareFacility.contact_type_keys.format=[string] diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityInitializer.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityInitializer.java new file mode 100644 index 000000000..d6ea6942c --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityInitializer.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Sören Bernstein, for the Center of Social Politics of the University of Bremen + * + * 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.cms.contenttypes.*; +import org.apache.log4j.Logger; +import com.arsdigita.runtime.LegacyInitEvent; + +/** + * Initializer of the HealthCareFacility content type. + * + * @author Sören Bernstein + */ +public class HealthCareFacilityInitializer extends ContentTypeInitializer { + + private static final Logger s_log = Logger.getLogger(HealthCareFacilityInitializer.class); + + /** + * Constructor. calls only the constructor of the parent class with name of + * the pdl.mf file of the content type an the BASIC_DATA_OBJECT_TYPE. + */ + public HealthCareFacilityInitializer() { + super("ccm-cms-types-healthCareFacility.pdl.mf", + HealthCareFacility.BASE_DATA_OBJECT_TYPE); + } + + /** + * + * @return path of the XSL stylesheet file. The stylesheet is very generic, because this + * contenttype will be used with the new mandalay theme only. + */ + public String getStylesheet() { + return "static/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xsl"; + } + + /** + * Calls the init method of the parent class. + * + * @param evt The init event. LegacyInitEvent is marked deprecated. What should be used insted? + */ + @Override + public void init(LegacyInitEvent evt) { + super.init(evt); + + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityLoader.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityLoader.java new file mode 100644 index 000000000..17ced5ef0 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityLoader.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Sören Bernstein, for the Center of Social Politics of the University of Bremen + * + * 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.cms.contenttypes.*; +import com.arsdigita.util.parameter.ResourceParameter; + +import org.apache.log4j.Logger; + +/** + * Loader for the HealthCareFacility content type. + * + * @author Sören Bernstein + */ +public class HealthCareFacilityLoader extends AbstractContentTypeLoader { + + private static final Logger s_log = Logger.getLogger(HealthCareFacilityLoader.class); + private static final String[] TYPES = { + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xml" + }; + private ResourceParameter m_template; + + /** + * Returns the value of the type string. + * + * @return The type string. + */ + public String[] getTypes() { + return TYPES; + } + + /** + * Constructor. + */ + public HealthCareFacilityLoader() { + super(); + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityResources.properties b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityResources.properties new file mode 100644 index 000000000..4e5bb4788 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacilityResources.properties @@ -0,0 +1,32 @@ +cms.contenttypes.ui.healthCareFacility.basic_properties=Eigenschaften von Pflegeeinrichtung +cms.contenttypes.ui.healthCareFacility.address=Adresse +cms.contenttypes.ui.healthCareFacility.contact=Kontakte +cms.contenttypes.ui.healthCareFacility.edit_basic_properties=Bearbeiten + +cms.contenttypes.ui.healthCareFacility.attach_address=Adresse verknüpfen +cms.contenttypes.ui.healthCareFacility.edit_address=Adresse bearbeiten +cms.contenttypes.ui.healthCareFacility.delete_address=Adresse löschen +cms.contenttypes.ui.healthCareFacility.emptyAddress=Zur Zeit ist keine Adresse verknüpft + +cms.contenttypes.ui.healthCareFacility.select_address=Bitte wählen Sie eine Eintrag vom Typ BaseAddress +cms.contenttypes.ui.healthCareFacility.select_address.change=Verändern +cms.contenttypes.ui.healthCareFacility.select_address.add=Verknüpfen +cms.contenttypes.ui.healthCareFacility.select_address.wrong_type=Der gewählte Eintrag ist nicht vom Typ BaseAddress +cms.contenttypes.ui.healthCareFacility.select_address.cancelled=Abbruch +cms.contenttypes.ui.healthCareFacility.delete_address.label=Wollen Sie die Verknüpfung zur Adresse entfernen? +cms.contenttypes.ui.healthCareFacility.delete_address.button_label=Löschen + +cms.contenttypes.ui.healthCareFacility.select_contact=Bitte wählen Sie eine Eintrag vom Typ BaseContact +cms.contenttypes.ui.healthCareFacility.add_contact=Kontakt verknüpfen + +cms.contenttypes.ui.healthCareFacility.contacts.none=Zur Zeit sind keine Kontaktinformationen verknüpft +cms.contenttypes.ui.healthCareFacility.contact.order=Pos +cms.contenttypes.ui.healthCareFacility.contact.type=Kontaktart +cms.contenttypes.ui.healthCareFacility.contact.title=Titel +cms.contenttypes.ui.healthCareFacility.contact.action=Aktionen + +cms.contenttypes.ui.healthCareFacility.confirm_delete=Sind sie sicher? + +cms.contenttypes.ui.healthCareFacility.contactType.key.verwaltung=Verwaltung +cms.contenttypes.ui.healthCareFacility.contactType.key.pflegeleitung=Pflegeleitung +cms.contenttypes.ui.healthCareFacility.contactType.key.medLeitung=Med. Leitung \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityAddressPropertiesStep.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityAddressPropertiesStep.java new file mode 100644 index 000000000..7ba650633 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityAddressPropertiesStep.java @@ -0,0 +1,113 @@ +/* + * HealthCareFacilityAddressPropertiesStep.java + * + * Created on 4. Juli 2009, 15:15 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Label; +import com.arsdigita.cms.contenttypes.BaseAddress; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; + +/** + * + * @author quasi + */ +public class HealthCareFacilityAddressPropertiesStep extends SimpleEditStep { + + public static final String ADD_ADDRESS_SHEET_NAME = "addAddress"; + public static final String EDIT_ADDRESS_SHEET_NAME = "editAddress"; + public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress"; + public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress"; + + /** + * Creates a new instance of HealthCareFacilityAddressPropertiesStep + */ + public HealthCareFacilityAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { + this(itemModel, parent, ""); + } + + public HealthCareFacilityAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { + super(itemModel, parent, prefix); + +// HealthCareFacility healthCareFacility = (HealthCareFacility)itemModel.getSelectedObject(state); + +//XXX +// if(/*healthCareFacility.getAddress() == null*/ true) { + BasicPageForm attachAddressSheet = new HealthCareFacilityAttachAddressPropertyForm(itemModel, this); + add(ADD_ADDRESS_SHEET_NAME, (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.attach_address").localize(), new WorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton()); + + /* Set the displayComponent for this step */ +// setDisplayComponent(getEmptyBaseAddressPropertySheet(itemModel)); + +// } else { + + // editAddress + BasicPageForm editAddressSheet = new HealthCareFacilityEditAddressPropertyForm(itemModel, this); + add(EDIT_ADDRESS_SHEET_NAME, (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.edit_address").localize(), new WorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton()); + +// BasicPageForm attachAddressSheet = new HealthCareFacilityAttachAddressPropertyForm(itemModel, this); +// add(CHANGE_ADDRESS_SHEET_NAME, (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.reattach_address").localize(), new WorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton()); + + BasicPageForm deleteAddressSheet = new HealthCareFacilityDeleteAddressForm(itemModel, this); + add(DELETE_ADDRESS_SHEET_NAME, (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.delete_address").localize(), new WorkflowLockedComponentAccess(deleteAddressSheet, itemModel), deleteAddressSheet.getSaveCancelSection().getCancelButton()); + + /* Set the displayComponent for this step */ + setDisplayComponent(getBaseAddressPropertySheet(itemModel)); +// } + + } + + public static Component getBaseAddressPropertySheet(ItemSelectionModel itemModel) { + + DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); + + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize(), "address." + BaseAddress.ADDRESS); + if(!HealthCareFacility.getConfig().getHideAddressPostalCode()) + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize(), "address." + BaseAddress.POSTAL_CODE); + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize(), "address." + BaseAddress.CITY); + if(!HealthCareFacility.getConfig().getHideAddressState()) + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize(), "address." + BaseAddress.STATE); + + if(!HealthCareFacility.getConfig().getHideAddressCountry()) { + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize(), + "address." + BaseAddress.ISO_COUNTRY_CODE, + new DomainObjectPropertySheet.AttributeFormatter() { + public String format(DomainObject item, + String attribute, + PageState state) { + BaseAddress baseAddress = ((HealthCareFacility)item).getAddress(); + if(baseAddress != null && baseAddress.getIsoCountryCode() != null) { + return BaseAddress.getCountryNameFromIsoCode(baseAddress.getIsoCountryCode()); + } else { + return (String)BaseAddressGlobalizationUtil.globalize + ("cms.ui.unknown").localize(); + } + } + }); + } + + return sheet; + + } + + public static Component getEmptyBaseAddressPropertySheet(ItemSelectionModel itemModel) { + return new Label(((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.emptyAddress").localize())); + } + +} diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityAttachAddressPropertyForm.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityAttachAddressPropertyForm.java new file mode 100644 index 000000000..c018a4c08 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityAttachAddressPropertyForm.java @@ -0,0 +1,145 @@ +/* + * HealthCareFacilityEditAddressPropertyForm.java + * + * Created on 8. Juli 2009, 10:27 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; +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.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; +import com.arsdigita.bebop.form.Submit; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.cms.contenttypes.BaseAddress; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; +import com.arsdigita.util.UncheckedWrapperException; + +import org.apache.log4j.Logger; + +/** + * + * @author quasi + */ +public class HealthCareFacilityAttachAddressPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger logger = Logger.getLogger(HealthCareFacilityPropertyForm.class); + + private HealthCareFacilityAddressPropertiesStep m_step; + private ItemSearchWidget m_itemSearch; + private SaveCancelSection m_saveCancelSection; + private final String ITEM_SEARCH = "healthCareFacilityAddress"; + + /** + * ID of the form + */ + public static final String ID = "HealthCareFacilityAttachAddress"; + + /** + * Constrctor taking an ItemSelectionModel + * + * @param itemModel + */ + public HealthCareFacilityAttachAddressPropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + /** + * Constrctor taking an ItemSelectionModel and an instance of HealthCareFacilityPropertiesStep. + * + * @param itemModel + * @param step + */ + public HealthCareFacilityAttachAddressPropertyForm(ItemSelectionModel itemModel, HealthCareFacilityAddressPropertiesStep step) { + super(ID, itemModel); + addSubmissionListener(this); + + addSaveCancelSection(); + + addInitListener(this); + addSubmissionListener(this); + + } + + @Override + public void addWidgets() { + add(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.select_address").localize())); + this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.BaseAddress")); + add(this.m_itemSearch); + } + + public void init(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + setVisible(state, true); + + if (healthCareFacility != null) { + data.put(ITEM_SEARCH, healthCareFacility.getAddress()); + } + } + + public void process(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { + healthCareFacility.setAddress((BaseAddress)data.get(ITEM_SEARCH)); + } + init(fse); + } + + + /** + * Creates the section with the save and the cancel button. + */ + public void addSaveCancelSection() { + try { + getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() { + + public void prepare(PrintEvent e) { + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(e.getPageState()); + Submit target = (Submit) e.getTarget(); + + if (healthCareFacility.getAddress() != null) { + target.setButtonLabel((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.select_address.change").localize()); + } else { + target.setButtonLabel((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.select_address.add").localize()); + } + } + }); + } catch (Exception ex) { + throw new UncheckedWrapperException("this cannot happen", ex); + } + } + + public void validate(FormSectionEvent e) throws FormProcessException { + if (e.getFormData().get(ITEM_SEARCH) == null) { + throw new FormProcessException((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.select_address.wrong_type").localize()); + } + } + + public void submitted(FormSectionEvent e) throws FormProcessException { + if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) { + init(e); + throw new FormProcessException((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.select_address.cancelled").localize()); + } + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactAddForm.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactAddForm.java new file mode 100644 index 000000000..f3c231407 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactAddForm.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2008 Sören Bernstein 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; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.BaseContact; +import com.arsdigita.cms.contenttypes.util.BaseContactGlobalizationUtil; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.contenttypes.BaseContactCollection; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; +import com.arsdigita.cms.ui.ItemSearchWidget; +import java.util.StringTokenizer; + +import org.apache.log4j.Logger; + +/** + * Generates a form for creating new localisations for the given category. + * + * This class is part of the admin GUI of CCM and extends the standard form + * in order to present forms for managing the multi-language categories. + * + * @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de + */ +public class HealthCareFacilityBaseContactAddForm extends BasicItemForm { + private static final Logger s_log = Logger.getLogger(HealthCareFacilityBaseContactAddForm.class); + + private HealthCareFacilityAddressPropertiesStep m_step; + private ItemSearchWidget m_itemSearch; + private SaveCancelSection m_saveCancelSection; + private final String ITEM_SEARCH = "healthCareFacilityAddress"; + + private ItemSelectionModel m_itemModel; + + /** Creates a new instance of CategoryLocalizationAddForm */ + public HealthCareFacilityBaseContactAddForm(ItemSelectionModel itemModel) { + + super("BaseContactEntryAddForm",itemModel); + m_itemModel = itemModel; + + } + + protected void addWidgets() { + + // Attach a Contact object + add(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.select_contact").localize())); + this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.BaseContact")); + add(this.m_itemSearch); + + // Contact type field + add(new Label(BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contact.type"))); + ParameterModel contactTypeParam = new StringParameter(BaseContactCollection.CONTACT_TYPE); + SingleSelect contactType = new SingleSelect(contactTypeParam); + contactType.addValidationListener(new NotNullValidationListener()); + contactType.addOption(new Option("", new Label((String)BaseContactGlobalizationUtil.globalize("cms.ui.select_one").localize()))); + + // Add the Options to the SingleSelect widget + StringTokenizer keyList = HealthCareFacility.getConfig().getContactTypeKeys(); + while(keyList.hasMoreElements()) { + String currentKey = keyList.nextToken(); + contactType.addOption(new Option(currentKey, ((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contactType.key." + currentKey).localize()))); + } + + add(contactType); + } + + public void init(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + setVisible(state, true); + } + + public void process(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + // + if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { + healthCareFacility.addContact((BaseContact)data.get(ITEM_SEARCH), + (String)data.get(BaseContactCollection.CONTACT_TYPE)); + } + + init(fse); + } +} diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactPropertiesStep.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactPropertiesStep.java new file mode 100644 index 000000000..c1d5dd030 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactPropertiesStep.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.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; +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: PhoBaseContactEntriesPropertiesStepva 287 2005-02-22 00:29:02Z sskracic $ + */ +public class HealthCareFacilityBaseContactPropertiesStep extends SimpleEditStep { + + /** The name of the editing sheet added to this step */ + private static String ADD_CONTACT_SHEET_NAME = "addContact"; + + public HealthCareFacilityBaseContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public HealthCareFacilityBaseContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addContactSheet = new HealthCareFacilityBaseContactAddForm(itemModel); + add(ADD_CONTACT_SHEET_NAME, + (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.add_contact").localize(), + new WorkflowLockedComponentAccess(addContactSheet, itemModel), + addContactSheet.getSaveCancelSection().getCancelButton()); + + HealthCareFacilityBaseContactTable contactsTable = new HealthCareFacilityBaseContactTable(itemModel); + setDisplayComponent(contactsTable); + + } + +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactTable.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactTable.java new file mode 100644 index 000000000..71cfe5e8c --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityBaseContactTable.java @@ -0,0 +1,267 @@ +/* + * Copyright (C) 2008 Sören Bernstein 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; + +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.BaseContact; +import com.arsdigita.cms.contenttypes.BaseContactCollection; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * Lists all existing contact entries for a selected contact. + * + * @author Sören Bernstein (quasimodo) quasi@barkhof.uni-bremen.de + */ +public class HealthCareFacilityBaseContactTable extends Table implements TableActionListener{ + + + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + + private ItemSelectionModel m_itemModel; + + /** + * Creates a new instance of HealthCareFacilityHealthCareFacilityTable + */ + public HealthCareFacilityBaseContactTable(final ItemSelectionModel itemModel) { + + super(); + this.m_itemModel = itemModel; + + // if table is empty: + setEmptyView(new Label(HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contacts.none"))); + TableColumnModel tab_model = getColumnModel(); + + // define columns + tab_model.add(new TableColumn(0, HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contact.order").localize(), TABLE_COL_EDIT)); + tab_model.add(new TableColumn(1, HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contact.type").localize())); + tab_model.add(new TableColumn(2, HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contact.title").localize())); + tab_model.add(new TableColumn(3, HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contact.action").localize(), TABLE_COL_DEL)); + + setModelBuilder(new HealthCareFacilityTableModelBuilder(itemModel)); + + tab_model.get(0).setCellRenderer(new EditCellRenderer()); + tab_model.get(3).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + + } + + /** + * XXXX + * + */ + private class HealthCareFacilityTableModelBuilder extends LockableImpl implements TableModelBuilder { + + private ItemSelectionModel m_itemModel; + + public HealthCareFacilityTableModelBuilder(ItemSelectionModel itemModel) { + m_itemModel = itemModel; + } + + public TableModel makeModel(Table table, PageState state) { + table.getRowSelectionModel().clearSelection(state); + HealthCareFacility healthCareFacility = (HealthCareFacility) m_itemModel.getSelectedObject(state); + return new HealthCareFacilityTableModel(table, state, healthCareFacility); + } + } + + /** + * XXX + * + */ + private class HealthCareFacilityTableModel implements TableModel { + + final private int MAX_DESC_LENGTH = 25; + + private Table m_table; + private BaseContactCollection m_baseContactCollection; + private BaseContact m_baseContact; + + private HealthCareFacilityTableModel(Table t, PageState ps, HealthCareFacility healthCareFacility) { + m_table = t; + m_baseContactCollection = healthCareFacility.getContacts(); + } + + public int getColumnCount() { + return m_table.getColumnModel().size(); + } + + /** + * Check collection for the existence of another row. + * + * If exists, fetch the value of current HealthCareFacilityEntryCollection object + * into m_healthCareFacilityEntry class variable. + */ + public boolean nextRow() { + + if(m_baseContactCollection != null && m_baseContactCollection.next()){ + m_baseContact = m_baseContactCollection.getBaseContact(); + return true; + + } else { + + return false; + + } + } + + /** + * Return the + * @see com.arsdigita.bebop.table.TableModel#getElementAt(int) + */ + public Object getElementAt(int columnIndex) { + switch (columnIndex){ + case 0: + return m_baseContactCollection.getContactOrder(); + case 1: + return (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contactType.key." + m_baseContactCollection.getContactType()).localize(); + case 2: + return m_baseContact.getTitle(); +// case 2: +// return (m_healthCareFacilityEntry.getDescription() != null && m_healthCareFacilityEntry.getDescription().length() > MAX_DESC_LENGTH) +// ? m_healthCareFacilityEntry.getDescription().substring(0, MAX_DESC_LENGTH) +// : m_healthCareFacilityEntry.getDescription(); + case 3: + return GlobalizationUtil.globalize("cms.ui.delete").localize(); + default: + return null; + } + } + + /** + * + * @see com.arsdigita.bebop.table.TableModel#getKeyAt(int) + */ + public Object getKeyAt(int columnIndex) { + return m_baseContact.getID(); + } + + } + + /** + * Check for the permissions to edit item and put either a Label or + * a ControlLink accordingly. + */ + private class EditCellRenderer 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); + HealthCareFacility healthCareFacility = (HealthCareFacility) m_itemModel.getSelectedObject(state); + + boolean canEdit = sm.canAccess(state.getRequest(), + SecurityManager.EDIT_ITEM, + healthCareFacility); + if(canEdit) { + ControlLink link = new ControlLink(value.toString()); + return link; + } else { + return new Label(value.toString()); + } + } + } + + /** + * Check for the permissions to delete item and put either a Label 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); + HealthCareFacility healthCareFacility = (HealthCareFacility) m_itemModel.getSelectedObject(state); + + boolean canDelete = sm.canAccess(state.getRequest(), + SecurityManager.DELETE_ITEM, + healthCareFacility); + if(canDelete) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.confirm_delete").localize()); + 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 edit and delete event. + */ + public void cellSelected(TableActionEvent evt) { + + PageState state = evt.getPageState(); + + // Get selected BaseContact + BaseContact baseContact = + new BaseContact(new BigDecimal(evt.getRowKey().toString())); + + // Get HealthCareFacility + HealthCareFacility healthCareFacility = (HealthCareFacility) m_itemModel.getSelectedObject(state); + + // Get selected column + TableColumn col = getColumnModel().get(evt.getColumn().intValue()); + + // Edit + if(col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) { + + } + + // Delete + if(col.getHeaderKey().toString().equals(TABLE_COL_DEL)) { + healthCareFacility.removeContactEntry(baseContact); + } + + } + + /** + * provide Implementation to TableActionListener method. + * Does nothing in our case. + */ + public void headSelected(TableActionEvent e) { + throw new UnsupportedOperationException("Not Implemented"); + } + + +} diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityDeleteAddressForm.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityDeleteAddressForm.java new file mode 100644 index 000000000..88ff86832 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityDeleteAddressForm.java @@ -0,0 +1,78 @@ +/* + * HealthCareFacilityDeleteAddressForm.java + * + * Created on 17. Juli 2009, 10:10 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; +import com.arsdigita.bebop.form.Submit; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.util.UncheckedWrapperException; + +/** + * + * @author quasi + */ +public class HealthCareFacilityDeleteAddressForm extends BasicPageForm implements FormProcessListener { + + /** + * ID of the form + */ + public static final String ID = "HealthCareFacilityDeleteAddress"; + + HealthCareFacilityDeleteAddressForm(ItemSelectionModel itemModel, HealthCareFacilityAddressPropertiesStep step) { + super(ID, itemModel); + addSaveCancelSection(); + } + + public void init(FormSectionEvent fse) { + + } + + public void addWidgets() { + add(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.delete_address.label").localize())); + } + + /** + * Creates the section with the save and the cancel button. + */ + public void addSaveCancelSection() { + try { + getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() { + + public void prepare(PrintEvent e) { + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(e.getPageState()); + Submit target = (Submit) e.getTarget(); + target.setButtonLabel((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.delete_address.button_label").localize()); + } + }); + } catch (Exception ex) { + throw new UncheckedWrapperException("this cannot happen", ex); + } + } + + public final void process(final FormSectionEvent fse) throws FormProcessException { + + final PageState state = fse.getPageState(); + final HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + if (healthCareFacility != null && healthCareFacility.getAddress() != null) { + healthCareFacility.unsetAddress(); + } + } + +} diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityEditAddressPropertyForm.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityEditAddressPropertyForm.java new file mode 100644 index 000000000..bcc5e1582 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityEditAddressPropertyForm.java @@ -0,0 +1,189 @@ +/* + * HealthCareFacilityEditAddressPropertyForm.java + * + * Created on 8. Juli 2009, 10:27 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +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.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.event.ParameterEvent; +import com.arsdigita.bebop.event.ParameterListener; +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.NotNullValidationListener; +import com.arsdigita.bebop.parameters.StringInRangeValidationListener; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.bebop.parameters.ParameterData; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +import java.util.Iterator; +import java.util.Map; +import com.arsdigita.cms.contenttypes.BaseAddress; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil; + +import org.apache.log4j.Logger; + +/** + * + * @author quasi + */ +public class HealthCareFacilityEditAddressPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger logger = Logger.getLogger(HealthCareFacilityPropertyForm.class); + + private HealthCareFacilityAddressPropertiesStep m_step; + + public static final String ADDRESS = BaseAddress.ADDRESS; + public static final String POSTAL_CODE = BaseAddress.POSTAL_CODE; + public static final String CITY = BaseAddress.CITY; + public static final String STATE = BaseAddress.STATE; + public static final String ISO_COUNTRY_CODE = BaseAddress.ISO_COUNTRY_CODE; + + /** + * ID of the form + */ + public static final String ID = "HealthCareFacilityEditAddress"; + + /** + * Constrctor taking an ItemSelectionModel + * + * @param itemModel + */ + public HealthCareFacilityEditAddressPropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + /** + * Constrctor taking an ItemSelectionModel and an instance of HealthCareFacilityPropertiesStep. + * + * @param itemModel + * @param step + */ + public HealthCareFacilityEditAddressPropertyForm(ItemSelectionModel itemModel, HealthCareFacilityAddressPropertiesStep step) { + super(ID, itemModel); + m_step = step; + addSubmissionListener(this); + } + + @Override + public void addWidgets() { + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize())); + ParameterModel addressParam = new StringParameter(ADDRESS); + addressParam.addParameterListener( new NotNullValidationListener( ) ); + addressParam.addParameterListener( new StringInRangeValidationListener(0, 1000) ); + TextArea address = new TextArea(addressParam); + address.setRows(5); + address.setCols(30); + add(address); + + if(!HealthCareFacility.getConfig().getHideAddressPostalCode()) { + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize())); + ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE); + TextField postalCode = new TextField(postalCodeParam); + /* XXX NumberListener ?*/ + add(postalCode); + } + + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize())); + ParameterModel cityParam = new StringParameter(CITY); + TextField city = new TextField(cityParam); + add(city); + + if(!HealthCareFacility.getConfig().getHideAddressState()) { + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize())); + ParameterModel stateParam = new StringParameter(STATE); + TextField state = new TextField(stateParam); + add(state); + } + + if (!HealthCareFacility.getConfig().getHideAddressCountry()) { + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize())); + ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE); + countryParam.addParameterListener(new StringInRangeValidationListener(0, 2)); + + SingleSelect country = new SingleSelect(countryParam); + + country.addOption(new Option("", new Label((String)BaseAddressGlobalizationUtil.globalize("cms.ui.select_one" ).localize()))); + + Iterator countries = BaseAddress.getSortedListOfCountries(null).entrySet().iterator(); + while(countries.hasNext()) { + Map.Entry elem = (Map.Entry)countries.next(); + country.addOption(new Option(elem.getValue().toString(), elem.getKey().toString())); + } + + country.addValidationListener( + new ParameterListener() { + public void validate(ParameterEvent e) throws FormProcessException { + ParameterData data = e.getParameterData(); + String isoCode = (String) data.getValue() ; + if (isoCode == null || isoCode.length() == 0) { + data.addError((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.error_iso_country").localize()); + } + } + } + ); + + add(country); + } + + } + + public void init(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + if(healthCareFacility.getAddress() != null) { + data.put(ADDRESS, healthCareFacility.getAddress().getAddress()); + data.put(POSTAL_CODE, healthCareFacility.getAddress().getPostalCode()); + data.put(CITY, healthCareFacility.getAddress().getCity()); + data.put(STATE, healthCareFacility.getAddress().getState()); + if(!BaseAddress.getConfig().getHideCountryCodeSelection()) { + data.put(ISO_COUNTRY_CODE, healthCareFacility.getAddress().getIsoCountryCode()); + } + } + } + + public void submitted(FormSectionEvent fse) { + if (m_step != null && + getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { + m_step.cancelStreamlinedCreation(fse.getPageState()); + } + } + + public void process(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + HealthCareFacility healthCareFacility = (HealthCareFacility)getItemSelectionModel().getSelectedObject(state); + + if (healthCareFacility.getAddress() != null && + getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { + healthCareFacility.getAddress().setAddress((String)data.get(ADDRESS)); + healthCareFacility.getAddress().setPostalCode((String)data.get(POSTAL_CODE)); + healthCareFacility.getAddress().setCity((String)data.get(CITY)); + healthCareFacility.getAddress().setState((String)data.get(STATE)); + healthCareFacility.getAddress().setIsoCountryCode((String)data.get(ISO_COUNTRY_CODE)); + + healthCareFacility.getAddress().save(); + } + + if (m_step != null) { + m_step.maybeForwardToNextStep(fse.getPageState()); + } + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityPropertiesStep.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityPropertiesStep.java new file mode 100644 index 000000000..df8c30cda --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityPropertiesStep.java @@ -0,0 +1,114 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.cms.ContentPage; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ItemSelectionModel; +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.domain.DomainObject; +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; +import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.SegmentedPanel; +import com.arsdigita.cms.contenttypes.HealthCareFacility; +import com.arsdigita.cms.contenttypes.util.HealthCareFacilityGlobalizationUtil; + +import java.text.DateFormat; +import org.apache.log4j.Logger; + +/** + * AuthoringStep for the basic properties of a basic contact + */ +public class HealthCareFacilityPropertiesStep extends SimpleEditStep { + + private static final Logger logger = Logger.getLogger(HealthCareFacilityPropertiesStep.class); + + /** + * Name of the this edit sheet (Don't know if this this really needed. + * It has the same value in almost all PropertiesStep classes) + */ + public static final String EDIT_BASIC_SHEET_NAME = "editBasic"; + + /** + * Constructor for the PropertiesStep. + * + * @param itemModel + * @param parent + */ + public HealthCareFacilityPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { + super(itemModel, parent); + + /* Use a Segmented Panel for the multiple parts of data */ + SegmentedPanel segmentedPanel = new SegmentedPanel(); + + setDefaultEditKey(EDIT_BASIC_SHEET_NAME); + + /* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */ + /* Well, not so simple anymore... */ + + /* A new SimpleEditStep */ + SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_BASIC_SHEET_NAME); + + /* Create the edit component for this SimpleEditStep and the corresponding link */ + BasicPageForm editBasicSheet = new HealthCareFacilityPropertyForm(itemModel, this); + basicProperties.add(EDIT_BASIC_SHEET_NAME, (String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton()); + + /* Set the displayComponent for this step */ + basicProperties.setDisplayComponent(getHealthCareFacilityPropertySheet(itemModel)); + + /* Add the SimpleEditStep to the segmented panel */ + segmentedPanel.addSegment(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.basic_properties").localize()), basicProperties); + + // If not disabled via registry, add the ui for attaching a baseAddress + if(!HealthCareFacility.getConfig().getHideAddress()) { + HealthCareFacilityAddressPropertiesStep addressProperties = new HealthCareFacilityAddressPropertiesStep(itemModel, parent); + segmentedPanel.addSegment(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.address").localize()), addressProperties); + } + + HealthCareFacilityBaseContactPropertiesStep baseContacts = new HealthCareFacilityBaseContactPropertiesStep(itemModel, parent); + segmentedPanel.addSegment(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.contact").localize()), baseContacts); + + /* Sets the composed segmentedPanel as display component */ + setDisplayComponent(segmentedPanel); + } + + /** + * Creates and returns the sheet for editing the basic properties + * of an organization. (@see HealthCareFacilityPropertyForm). + * + * + * @param itemModel + * @return The sheet for editing the properties of the organization. + */ + public static Component getHealthCareFacilityPropertySheet(ItemSelectionModel itemModel) { + + + /* The DisplayComponent for the Basic Properties */ + DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); + + sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),"name"); + sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"),"title"); + + if(!ContentSection.getConfig().getHideLaunchDate()) { + sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() { + + public String format(DomainObject obj, String attribute, PageState state) { + ContentPage page = (ContentPage)obj; + if(page.getLaunchDate() != null) { + return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate()); + } + else { + return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize(); + } + } + }); + } + + return sheet; + } + +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityPropertyForm.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityPropertyForm.java new file mode 100644 index 000000000..9c3f3063a --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/ui/HealthCareFacilityPropertyForm.java @@ -0,0 +1,97 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +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.cms.ItemSelectionModel; +import com.arsdigita.bebop.FormData; +import com.arsdigita.cms.contenttypes.HealthCareFacility; + +import org.apache.log4j.Logger; + +/** + * Form for editing the basic properties of a basic contact. + */ +public class HealthCareFacilityPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger logger = Logger.getLogger(HealthCareFacilityPropertyForm.class); + + private HealthCareFacilityPropertiesStep m_step; + + public static final String ADRESS = HealthCareFacility.ADDRESS; + public static final String CONTACTS= HealthCareFacility.CONTACTS; + + /** + * ID of the form + */ + public static final String ID = "HealthCareFacility_edit"; + + /** + * Constrctor taking an ItemSelectionModel + * + * @param itemModel + */ + public HealthCareFacilityPropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + /** + * Constrctor taking an ItemSelectionModel and an instance of HealthCareFacilityPropertiesStep. + * + * + * @param itemModel + * @param step + */ + public HealthCareFacilityPropertyForm(ItemSelectionModel itemModel, HealthCareFacilityPropertiesStep step) { + super(ID, itemModel); + m_step = step; + addSubmissionListener(this); + } + + @Override + public void addWidgets() { + super.addWidgets(); + +/* + add(new Label((String)HealthCareFacilityGlobalizationUtil.globalize("cms.contenttypes.ui.healthCareFacility.basic_properties.description").localize()))); + TextArea description = new TextArea(DESCRIPTION); + description.setRows(5); + description.setCols(30); + add(description); +*/ + } + + @Override + public void init(FormSectionEvent e) throws FormProcessException { + FormData data = e.getFormData(); + HealthCareFacility healthCareFacility = (HealthCareFacility)super.initBasicWidgets(e); + +// data.put(DESCRIPTION, healthCareFacility.getDescription()); + } + + @Override + public void process(FormSectionEvent e) throws FormProcessException { + FormData data = e.getFormData(); + + HealthCareFacility healthCareFacility = (HealthCareFacility)super.processBasicWidgets(e); + + if((healthCareFacility != null) && (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) { +// healthCareFacility.setDescription((String)data.get(DESCRIPTION)); + + healthCareFacility.save(); + } + + if(m_step != null) { + m_step.maybeForwardToNextStep(e.getPageState()); + } + } + + public void submitted(FormSectionEvent e) throws FormProcessException { + if((m_step != null) && (getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) { + m_step.cancelStreamlinedCreation(e.getPageState()); + } + } +} \ No newline at end of file diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/util/HealthCareFacilityGlobalizationUtil.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/util/HealthCareFacilityGlobalizationUtil.java new file mode 100644 index 000000000..9122e9ce8 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/util/HealthCareFacilityGlobalizationUtil.java @@ -0,0 +1,53 @@ +/* + * 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 + *

+ * + * @author randyg@arsdigita.com + * @version $Revision: #4 $ $Date: 2004/08/17 $ + */ + +public class HealthCareFacilityGlobalizationUtil { + + final public static String BUNDLE_NAME = + "com.arsdigita.cms.contenttypes.util.HealthCareFacilityResourceBundle"; + + /** + * This returns a globalized message using the type specific bundle, + * BUNDLE_NAME + */ + public static GlobalizedMessage globalize(String key) { + return new GlobalizedMessage(key, BUNDLE_NAME); + } + + /** + * This returns a globalized message using the type specific bundle, + * BUNDLE_NAME + */ + public static GlobalizedMessage globalize(String key, Object[] args) { + return new GlobalizedMessage(key, BUNDLE_NAME, args); + } +} diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/util/HealthCareFacilityResourceBundle.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/util/HealthCareFacilityResourceBundle.java new file mode 100644 index 000000000..d268234a7 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/util/HealthCareFacilityResourceBundle.java @@ -0,0 +1,39 @@ +/* + * 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; + +/** + * Form to edit the basic properties of an event. This form can be extended to + * create forms for Event subclasses. + **/ +public class HealthCareFacilityResourceBundle extends ChainedResourceBundle implements CMSGlobalized { + + public final static String HEALTH_CARE_FACILITY_BUNDLE_NAME = + "com.arsdigita.cms.contenttypes.HealthCareFacilityResources"; + + public HealthCareFacilityResourceBundle() { + super(); + addBundle((PropertyResourceBundle)getBundle(HEALTH_CARE_FACILITY_BUNDLE_NAME)); + addBundle((PropertyResourceBundle)getBundle(BUNDLE_NAME)); + } +} diff --git a/ccm-cms-types-healthCareFacility/web/static/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xsl b/ccm-cms-types-healthCareFacility/web/static/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xsl new file mode 100644 index 000000000..531c92cc7 --- /dev/null +++ b/ccm-cms-types-healthCareFacility/web/static/content-types/com/arsdigita/cms/contenttypes/HealthCareFacility.xsl @@ -0,0 +1,41 @@ + +]> + + + + +
+ + + + + + +
+ +
+ + + + + + + +
Address:
+
+ + + +

+ + Address +
+
+
+ + \ No newline at end of file