diff --git a/ccm-cms-assets-relatedlink/pdl/com/arsdigita/contentassets/RelatedLink.pdl b/ccm-cms-assets-relatedlink/pdl/com/arsdigita/contentassets/RelatedLink.pdl
index 4f21e731a..6f5a0660d 100755
--- a/ccm-cms-assets-relatedlink/pdl/com/arsdigita/contentassets/RelatedLink.pdl
+++ b/ccm-cms-assets-relatedlink/pdl/com/arsdigita/contentassets/RelatedLink.pdl
@@ -21,6 +21,7 @@ import com.arsdigita.cms.MimeType;
object type RelatedLink extends Link {
+ String[0..1] linkListName = cms_related_links.link_list_name VARCHAR(100);
String[0..1] resourceSize = cms_related_links.resource_size VARCHAR(50);
MimeType[0..1] resourceType = join cms_related_links.resource_type
to cms_mime_types.mime_type;
@@ -56,7 +57,7 @@ query allRelatedLinkOrderForItem {
do {
select l.link_order from cms_links l, cms_related_links r
- where r.owner_id = :ownerID and l.link_id = r.related_link_id
+ where r.owner_id = :ownerID and l.link_id = r.related_link_id and r.link_list_name = :linkListName
} map {
linkOrder = l.link_order;
}
@@ -68,7 +69,7 @@ query getReferringRelatedLinks {
do {
select l.link_id
from cms_links l, cms_related_links r
- where l.target_item_id = :itemID and l.link_id=r.related_link_id
+ where l.target_item_id = :itemID and l.link_id=r.related_link_id and r.link_list_name = :linkListName
} map {
id = l.link_id;
}
diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLink.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLink.java
index f6ecbde4b..4c36d4b7c 100755
--- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLink.java
+++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLink.java
@@ -44,6 +44,7 @@ public class RelatedLink extends Link {
private static final Logger s_log = Logger.getLogger(RelatedLink.class);
/** PDL properties */
+ public static final String LINK_LIST_NAME = "linkListName";
public static final String RESOURCE_SIZE = "resourceSize";
public static final String RESOURCE_TYPE = "resourceType";
public static final String LINK_OWNER = "linkOwner";
@@ -108,6 +109,16 @@ public class RelatedLink extends Link {
super( type );
}
+ /** get the name of the named link list. */
+ public String getLinkListName(){
+ return (String) get(LINK_LIST_NAME);
+ }
+
+ /** Set the name of the named link list. */
+ public void setLinkListName(String name){
+ set(LINK_LIST_NAME , name);
+ }
+
/**
* Get the MimeType of the target resource to which this link points.
*
@@ -171,15 +182,16 @@ public class RelatedLink extends Link {
*
* @param item The item to return links for
*/
- public static DataCollection getRelatedLinks(ContentItem item) {
+ public static DataCollection getRelatedLinks(ContentItem item, String name) {
s_log.debug("Getting related links for a content item");
Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
links.addEqualsFilter(LINK_OWNER + ".id", item.getID());
+ links.addEqualsFilter(LINK_LIST_NAME, name);
links.addOrder(ORDER);
return links;
}
-
+
/**
* Returns a DataCollection of related links which refer to the
* given item.
@@ -261,6 +273,7 @@ public class RelatedLink extends Link {
Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
links.addEqualsFilter(LINK_OWNER + ".id", getLinkOwner().getID());
+ links.addEqualsFilter(LINK_LIST_NAME, getLinkListName());
links.addOrder(TITLE);
int sortKey = 0;
while (links.next()) {
@@ -287,6 +300,7 @@ public class RelatedLink extends Link {
DataQuery query = SessionManager.getSession().retrieveQuery
("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem");
query.setParameter("ownerID", getLinkOwner().getID());
+ query.setParameter("linkListName", getLinkListName());
query.addOrder("linkOrder DESC");
if (query.next()) {
Integer linkOrder = ((Integer)query.get("linkOrder"));
diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java
index 32348ead3..5c3c337cd 100755
--- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java
+++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java
@@ -27,7 +27,9 @@ import com.arsdigita.cms.contenttypes.ui.LinkTable;
* Authoring step to create a RelatedLink and change ordering.
*/
public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
-
+
+ protected String m_linkListName = "";
+
/**
* Constructor. Creates a RelatedLinkPropertiesStep given an
* ItemSelectionModel and an
@@ -63,10 +65,9 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
LinkTable table;
if (ContentSection.getConfig().isHideAdditionalResourceFields()) {
table = new LinkTable(getItemSelectionModel(), getLinkSelectionModel());
- table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel()));
+ table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), m_linkListName));
} else {
- table = new RelatedLinkTable(getItemSelectionModel(),
- getLinkSelectionModel());
+ table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), m_linkListName);
}
container.add(table);
@@ -81,7 +82,8 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
@Override
protected FormSection getEditSheet() {
return new RelatedLinkPropertyForm(getItemSelectionModel(),
- getLinkSelectionModel());
+ getLinkSelectionModel(),
+ m_linkListName);
}
}
diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java
index c904e721c..3099bbf38 100755
--- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java
+++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java
@@ -19,6 +19,7 @@ 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.Hidden;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField;
@@ -49,6 +50,7 @@ import com.arsdigita.util.Assert;
public class RelatedLinkPropertyForm extends LinkPropertyForm {
private static boolean isHideAdditionalResourceFields;
+ private String m_linkListName = "";
static {
isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
@@ -63,7 +65,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* Link to work on
*/
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
- LinkSelectionModel link) {
+ LinkSelectionModel link, String linkListName) {
super(itemModel, link);
}
@@ -99,6 +101,9 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
addMimeOptions(resType);
add(resType);
}
+
+ Hidden linkListName = new Hidden(new StringParameter(RelatedLink.LINK_LIST_NAME));
+ add(linkListName);
}
/**
@@ -124,6 +129,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* @param s the PageState
* @return the newly-created RelatedLink
*/
+ @Override
protected Link createLink(PageState s) {
ContentItem item = getContentItem(s);
Assert.exists(item, ContentItem.class);
@@ -141,6 +147,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* Over-ride super class method to initialize addtional fields specific
* to RelatedLink content asset.
*/
+ @Override
public void init(FormSectionEvent fse) throws FormProcessException {
super.init(fse);
FormData data = fse.getFormData();
@@ -156,10 +163,12 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
if (rl.getResourceType() != null) {
data.put(RelatedLink.RESOURCE_TYPE, rl.getResourceType().getMimeType());
}
+ data.put(RelatedLink.LINK_LIST_NAME, rl.getLinkListName());
} else {
// New Link creation , clear the fields.
data.put(RelatedLink.RESOURCE_SIZE, null);
data.put(RelatedLink.RESOURCE_TYPE, null);
+ data.put(RelatedLink.LINK_LIST_NAME, m_linkListName);
}
}
}
@@ -168,6 +177,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* over-ride super class method to set extended properties for
* RelatedLink.
*/
+ @Override
protected void setLinkProperties(Link link, FormSectionEvent fse) {
RelatedLink rl = (RelatedLink) (link);
FormData data = fse.getFormData();
@@ -181,6 +191,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
MimeType mType = MimeType.loadMimeType(typeName);
rl.setResourceType(mType);
}
+ rl.setLinkListName(data.getString(RelatedLink.LINK_LIST_NAME));
super.setLinkProperties(link, fse);
}
}
diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTable.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTable.java
index 1562283d5..d2c8e2501 100755
--- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTable.java
+++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTable.java
@@ -48,10 +48,10 @@ public class RelatedLinkTable extends LinkTable {
* @param link The LinkSelectionModel to track the
* current link
*/
- public RelatedLinkTable(ItemSelectionModel item, LinkSelectionModel link) {
+ public RelatedLinkTable(ItemSelectionModel item, LinkSelectionModel link, String linkListName) {
super(item, link);
- setModelBuilder(new RelatedLinkTableModelBuilder(item));
+ setModelBuilder(new RelatedLinkTableModelBuilder(item, linkListName));
RelatedLinkRenderer rlcr = new RelatedLinkRenderer();
m_typeCol.setCellRenderer(rlcr);
diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTableModelBuilder.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTableModelBuilder.java
index 15a7da54a..23debfce4 100755
--- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTableModelBuilder.java
+++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkTableModelBuilder.java
@@ -31,12 +31,12 @@ import org.apache.log4j.Logger;
* @author Scott Seago (sseago@redhat.com)
*/
-public class RelatedLinkTableModelBuilder
- extends LinkTableModelBuilder {
+public class RelatedLinkTableModelBuilder extends LinkTableModelBuilder {
private static final Logger s_log =
Logger.getLogger(RelatedLinkTableModelBuilder.class);
private ItemSelectionModel m_itemModel;
+ private String m_linkListName = "";
/**
* Constructor. Creates a LinkTableModelBuilder given an
@@ -45,8 +45,9 @@ public class RelatedLinkTableModelBuilder
* @param item The ItemSelectionModel for the current page.
* current link
*/
- public RelatedLinkTableModelBuilder(ItemSelectionModel item) {
+ public RelatedLinkTableModelBuilder(ItemSelectionModel item, String name) {
m_itemModel = item;
+ m_linkListName = name;
s_log.debug("RelatedLinkTableModelBuilder");
}
@@ -61,7 +62,7 @@ public class RelatedLinkTableModelBuilder
Assert.isTrue(m_itemModel.isSelected(s), "item selected");
ContentItem item = m_itemModel.getSelectedItem(s);
s_log.debug("Getting related links for " + item.getName());
- return RelatedLink.getRelatedLinks(item);
+ return RelatedLink.getRelatedLinks(item, m_linkListName);
}
}
diff --git a/ccm-cms/pdl/com/arsdigita/content-section/RelationAttribute.pdl b/ccm-cms/pdl/com/arsdigita/content-section/RelationAttribute.pdl
index 912673b10..bc7e9bc9e 100644
--- a/ccm-cms/pdl/com/arsdigita/content-section/RelationAttribute.pdl
+++ b/ccm-cms/pdl/com/arsdigita/content-section/RelationAttribute.pdl
@@ -25,12 +25,12 @@ object type RelationAttribute {
BigDecimal[1..1] id = cms_relation_attribute.object_id INTEGER;
String[1..1] attribute = cms_relation_attribute.attribute VARCHAR(100);
- String[1..1] key = cms_relation_attribute.key VARCHAR(100);
+ String[1..1] attr_key = cms_relation_attribute.attr_key VARCHAR(100);
String[1..1] lang = cms_relation_attribute.lang VARCHAR(2);
String[1..1] name = cms_relation_attribute.name VARCHAR(100);
String[0..1] description = cms_relation_attribute.description VARCHAR(500);
- unique (attribute, key, lang);
+ unique (attribute, attr_key, lang);
object key (id);
}
diff --git a/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl b/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl
index 3c5e36fda..705bd3211 100644
--- a/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl
+++ b/ccm-cms/pdl/com/arsdigita/content-types/GenericContact.pdl
@@ -57,7 +57,7 @@ association {
to cms_contacts.contact_id;
// Link Attribute
- BigDecimal[0..1] contact_order = cms_person_contact_map.contact_order INTEGER;
- String[0..1] contact_type = cms_person_contact_map.key VARCHAR(100);
+ BigDecimal[0..1] link_order = cms_person_contact_map.link_order INTEGER;
+ String[0..1] link_key = cms_person_contact_map.link_key VARCHAR(100);
}
diff --git a/ccm-cms/src/com/arsdigita/cms/RelationAttribute.java b/ccm-cms/src/com/arsdigita/cms/RelationAttribute.java
index a1d3fcdc6..497dc9144 100644
--- a/ccm-cms/src/com/arsdigita/cms/RelationAttribute.java
+++ b/ccm-cms/src/com/arsdigita/cms/RelationAttribute.java
@@ -19,7 +19,7 @@ public class RelationAttribute extends DomainObject {
public static final String ID = "id";
public static final String ATTRIBUTE = "attribute";
- public static final String KEY = "key";
+ public static final String KEY = "attr_key";
public static final String LANGUAGE = "lang";
public static final String NAME = "name";
public static final String DESCRIPTION = "description";
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java
index 95f97803b..d4179d021 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java
@@ -39,6 +39,7 @@ public class GenericContact extends ContentPage implements RelationAttributeInte
/** PDL property names */
public static final String PERSON = "person";
+// public static final String CONTACT_TYPE = "";
public static final String ADDRESS = "address";
public static final String CONTACT_ENTRIES = "contactentries";
@@ -98,12 +99,22 @@ public class GenericContact extends ContentPage implements RelationAttributeInte
public GenericPerson getPerson() {
return (GenericPerson) DomainObjectFactory.newInstance((DataObject)get(PERSON));
}
-
+
// Set the person for this contact
public void setPerson(GenericPerson person) {
set(PERSON, person);
}
-
+
+// // Get the type for this contact
+// public String getContactType() {
+// return get(CONTACT_TYPE));
+// }
+//
+// // Set the type for this contact
+// public void setContactType(String type) {
+// set(CONTACT_TYPE, type);
+// }
+
// Unset the address for this contact
public void unsetPerson() {
set(PERSON, null);
@@ -141,6 +152,14 @@ public class GenericContact extends ContentPage implements RelationAttributeInte
remove(CONTACT_ENTRIES, contactEntry);
}
+ public boolean hasPerson() {
+ return !(this.getPerson() == null);
+ }
+
+ public boolean hasAddress() {
+ return !(this.getAddress() == null);
+ }
+
public boolean hasContactEntries() {
return !this.getContactEntries().isEmpty();
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContactTypeCollection.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContactTypeCollection.java
index ea8780f0c..62cf15efc 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContactTypeCollection.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContactTypeCollection.java
@@ -16,17 +16,19 @@ import com.arsdigita.persistence.DataCollection;
*/
public class GenericContactTypeCollection extends RelationAttributeCollection {
- public static final String CONTACT_ORDER = "contact_order";
+ public static final String CONTACTS_KEY = GenericPerson.CONTACTS_KEY;
+ public static final String CONTACTS_ORDER = GenericPerson.CONTACTS_ORDER;
+ public static final String ATTRIBUTE_NAME = "person";
/**
* Creates a new instance of GenericContactEntryCollection
*/
public GenericContactTypeCollection() {
- super("person");
+ super(ATTRIBUTE_NAME);
}
public GenericContactTypeCollection(String key) {
- super("person", key);
+ super(ATTRIBUTE_NAME, CONTACTS_KEY);
}
public GenericContactTypeCollection(DataCollection dataCollection) {
@@ -38,6 +40,6 @@ public class GenericContactTypeCollection extends RelationAttributeCollection {
// }
public String getContactOrder() {
- return (String) get(CONTACT_ORDER);
+ return (String) get(CONTACTS_ORDER);
}
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java
index 5d9e4e0e6..2a1cf3c5a 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPerson.java
@@ -46,8 +46,8 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
public static final String BIRTHDATE = "birthdate";
public static final String GENDER = "gender";
public static final String CONTACTS = "contacts";
- public static final String CONTACT_TYPE = "contact_type";
- public static final String CONTACT_ORDER = "contact_order";
+ public static final String CONTACTS_KEY = "link_key";
+ public static final String CONTACTS_ORDER = "link_order";
private static final String RELATION_ATTRIBUTES = "GenericContactType";
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE =
@@ -166,9 +166,11 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
private void updateNameAndTitle() {
// Sync title and name with CI data
- setTitle(getFullName());
- setName(GenericPerson.urlSave(getTitle()));
-
+ String fullname = getFullName();
+ if (fullname != null && !fullname.isEmpty()) {
+ setTitle(fullname);
+ setName(GenericPerson.urlSave(fullname));
+ }
}
// Get all contacts for this person
@@ -183,8 +185,8 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
DataObject link = add(CONTACTS, contact);
- link.set(CONTACT_TYPE, contactType);
- link.set(CONTACT_ORDER, BigDecimal.valueOf(getContacts().size()));
+ link.set(CONTACTS_KEY, contactType);
+ link.set(CONTACTS_ORDER, BigDecimal.valueOf(getContacts().size()));
}
// Remove a contact for this person
@@ -210,18 +212,24 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
// Create a ulr save version of the full name
public static String urlSave(String in) {
- // Replacement map
- String[][] replacements = {{"ä", "ae"}, {"Ä", "Ae"}, {"ö", "oe"}, {"Ö", "Oe"}, {"ü", "ue"}, {"Ü", "Ue"}, {"ß", "ss"}, {".", ""}};
+ if (in != null && !in.isEmpty()) {
- // Replace all spaces with dash
- String out = in.replace(" ", "-");
+ // Replacement map
+ String[][] replacements = {{"ä", "ae"}, {"Ä", "Ae"}, {"ö", "oe"}, {"Ö", "Oe"}, {"ü", "ue"}, {"Ü", "Ue"}, {"ß", "ss"}, {".", ""}};
- // Replace all special chars defined in replacement map
- for (int i = 0; i < replacements.length; i++) {
- out = out.replace(replacements[i][0], replacements[i][1]);
+ // Replace all spaces with dash
+ String out = in.replace(" ", "-");
+
+ // Replace all special chars defined in replacement map
+ for (int i = 0; i < replacements.length; i++) {
+ out = out.replace(replacements[i][0], replacements[i][1]);
+ }
+
+ // Replace all special chars that are not yet replaced with a dash
+ return out.replaceAll("[^A-Za-z0-9-]", "_");
}
- // Replace all special chars that are not yet replaced with a dash
- return out.replaceAll("[^A-Za-z0-9-]", "_");
+ return in;
+
}
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPersonContactCollection.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPersonContactCollection.java
index 3fbfd64f7..9abfd63e7 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPersonContactCollection.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericPersonContactCollection.java
@@ -19,9 +19,9 @@ import java.math.BigDecimal;
*/
public class GenericPersonContactCollection 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";
+ public static final String ORDER = "link." + GenericPerson.CONTACTS_ORDER + " asc";
+ public static final String CONTACTS_KEY = "link." + GenericPerson.CONTACTS_KEY;
+ public static final String CONTACTS_ORDER = "link." + GenericPerson.CONTACTS_ORDER;
/**
* Creates a new instance of GenericPersonContactCollection
@@ -34,12 +34,12 @@ public class GenericPersonContactCollection extends DomainCollection {
// Get the contact type of the link
public String getContactType() {
- return (String) m_dataCollection.get(CONTACT_TYPE);
+ return (String) m_dataCollection.get(CONTACTS_KEY);
}
// Get the contact order of the link
public String getContactOrder() {
- String retVal = ((BigDecimal) m_dataCollection.get(CONTACT_ORDER)).toString();
+ String retVal = ((BigDecimal) m_dataCollection.get(CONTACTS_ORDER)).toString();
if(retVal == null || retVal.isEmpty()) {
retVal = String.valueOf(this.getPosition());
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java
index a6ef283e1..c3ee43244 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAttachPersonPropertyForm.java
@@ -51,6 +51,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "contactPerson";
+ private final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY;
/**
* ID of the form
*/
@@ -90,7 +91,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
- ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACT_TYPE);
+ ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
@@ -116,6 +117,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
if (contact != null) {
data.put(ITEM_SEARCH, contact.getPerson());
+// data.put(CONTACTS_KEY, contact.getContactType());
}
}
@@ -126,6 +128,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
contact.setPerson((GenericPerson) data.get(ITEM_SEARCH));
+// contact.setContactType(data.get(CONTACTS_KEY));
}
init(fse);
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactEditAddressPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactEditAddressPropertyForm.java
index b5d36ac24..549967607 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactEditAddressPropertyForm.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactEditAddressPropertyForm.java
@@ -168,11 +168,11 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state);
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
- if (contact.getAddress() == null) {
- contact.setAddress(new GenericAddress());
- contact.getAddress().setName("Address for " + contact.getName() + "(" + contact.getID() + ")");
- contact.getAddress().setTitle("Address for " + contact.getName() + "(" + contact.getID() + ")");
- }
+// if (contact.getAddress() == null) {
+// contact.setAddress(new GenericAddress());
+// contact.getAddress().setName("Address for " + contact.getName() + "(" + contact.getID() + ")");
+// contact.getAddress().setTitle("Address for " + contact.getName() + "(" + contact.getID() + ")");
+// }
contact.getAddress().setAddress((String) data.get(ADDRESS));
contact.getAddress().setPostalCode((String) data.get(POSTAL_CODE));
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java
index c50a75d00..ded792a52 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactPersonPropertiesStep.java
@@ -6,7 +6,6 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.cms.ItemSelectionModel;
@@ -17,6 +16,8 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
@@ -25,11 +26,14 @@ import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
* @author quasi
*/
public class GenericContactPersonPropertiesStep extends SimpleEditStep {
-
+
public static final String ADD_PERSON_SHEET_NAME = "addPerson";
public static final String EDIT_PERSON_SHEET_NAME = "editPerson";
public static final String CHANGE_PERSON_SHEET_NAME = "changePerson";
public static final String DELETE_PERSON_SHEET_NAME = "deletePerson";
+ private WorkflowLockedComponentAccess addPerson;
+ private WorkflowLockedComponentAccess editPerson;
+ private WorkflowLockedComponentAccess delPerson;
/**
* Creates a new instance of GenericContactPersonPropertiesStep
@@ -37,48 +41,55 @@ public class GenericContactPersonPropertiesStep extends SimpleEditStep {
public GenericContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, "");
}
-
+
public GenericContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
-
-//XXX
-// if(false/*EMPTY*/) {
-
- BasicPageForm addPersonSheet = new GenericContactAttachPersonPropertyForm(itemModel, this);
- add(ADD_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_person").localize(), new WorkflowLockedComponentAccess(addPersonSheet, itemModel), addPersonSheet.getSaveCancelSection().getCancelButton());
- /* Set the displayComponent for this step */
-// setDisplayComponent(getEmptyPersonPropertySheet(itemModel));
+ BasicPageForm addPersonSheet = new GenericContactAttachPersonPropertyForm(itemModel, this);
+ addPerson = new WorkflowLockedComponentAccess(addPersonSheet, itemModel);
+ add(ADD_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_person").localize(), addPerson, addPersonSheet.getSaveCancelSection().getCancelButton());
-// } else {
-
- BasicPageForm editPersonSheet = new GenericContactEditPersonPropertyForm(itemModel, this);
- add(EDIT_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_person").localize(), new WorkflowLockedComponentAccess(editPersonSheet, itemModel), editPersonSheet.getSaveCancelSection().getCancelButton());
-
-// BasicPageForm changePersonSheet = new GenericContactEditPersonPropertyForm(itemModel, this);
-// add(CHANGE_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.reattach_person").localize(), new WorkflowLockedComponentAccess(changePersonSheet, itemModel), changePersonSheet.getSaveCancelSection().getCancelButton());
-
- BasicPageForm deletePersonSheet = new GenericContactDeletePersonForm(itemModel, this);
- add(DELETE_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_person").localize(), new WorkflowLockedComponentAccess(deletePersonSheet, itemModel), deletePersonSheet.getSaveCancelSection().getCancelButton());
+ BasicPageForm editPersonSheet = new GenericContactEditPersonPropertyForm(itemModel, this);
+ editPerson = new WorkflowLockedComponentAccess(editPersonSheet, itemModel);
+ add(EDIT_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_person").localize(), editPerson, editPersonSheet.getSaveCancelSection().getCancelButton());
- /* Set the displayComponent for this step */
- setDisplayComponent(getPersonPropertySheet(itemModel));
-// }
+ BasicPageForm deletePersonSheet = new GenericContactDeletePersonForm(itemModel, this);
+ delPerson = new WorkflowLockedComponentAccess(deletePersonSheet, itemModel);
+ add(DELETE_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_person").localize(), delPerson, deletePersonSheet.getSaveCancelSection().getCancelButton());
+
+ /* Set the displayComponent for this step */
+ setDisplayComponent(getPersonPropertySheet(itemModel));
}
public static Component getPersonPropertySheet(ItemSelectionModel itemModel) {
- DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
+ DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
- sheet.add((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), "person." + GenericPerson.SURNAME);
- sheet.add((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), "person." + GenericPerson.GIVENNAME);
- sheet.add((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), "person." + GenericPerson.TITLEPRE);
- sheet.add((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), "person." + GenericPerson.TITLEPOST);
-
- return sheet;
+ sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), "person." + GenericPerson.SURNAME);
+ sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), "person." + GenericPerson.GIVENNAME);
+ sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), "person." + GenericPerson.TITLEPRE);
+ sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), "person." + GenericPerson.TITLEPOST);
+
+ return sheet;
}
-
+
public static Component getEmptyPersonPropertySheet(ItemSelectionModel itemModel) {
- return new Label(((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyPerson").localize()));
+ return new Label(((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyPerson").localize()));
+ }
+
+ @Override
+ public boolean isVisible(PageState ps) {
+
+ if(((GenericContact) getItemSelectionModel().getSelectedItem(ps)).hasPerson() == false) {
+ addPerson.getComponent().setVisible(ps, true);
+ editPerson.getComponent().setVisible(ps, false);
+ delPerson.getComponent().setVisible(ps, false);
+ } else {
+ addPerson.getComponent().setVisible(ps, false);
+ editPerson.getComponent().setVisible(ps, true);
+ delPerson.getComponent().setVisible(ps, true);
+ }
+
+ return super.isVisible(ps);
}
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java
index a1154a67c..639288660 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactAddForm.java
@@ -77,7 +77,7 @@ public class GenericPersonContactAddForm extends BasicItemForm {
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
- ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACT_TYPE);
+ ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
@@ -109,7 +109,7 @@ public class GenericPersonContactAddForm extends BasicItemForm {
//
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
- person.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericPersonContactCollection.CONTACT_TYPE));
+ person.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericPersonContactCollection.CONTACTS_KEY));
}
init(fse);
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java
index f53a7d42c..7ec4a7809 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java
@@ -74,7 +74,7 @@ public class GenericPersonContactTable extends Table implements TableActionListe
setModelBuilder(new GenericPersonTableModelBuilder(itemModel));
- tab_model.get(0).setCellRenderer(new EditCellRenderer());
+ tab_model.get(2).setCellRenderer(new EditCellRenderer());
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
@@ -150,18 +150,10 @@ public class GenericPersonContactTable extends Table implements TableActionListe
case 0:
return m_contactCollection.getContactOrder();
case 1:
- String lang = DispatcherHelper.getNegotiatedLocale().getLanguage();
- String key = m_contactCollection.getContactType();
return contacttypes.getRelationAttribute(m_contactCollection.getContactType(),
- DispatcherHelper.getNegotiatedLocale().getLanguage());
-// return contacttypes.getRelationAttribute(m_contactCollection.getContactType(),
-// DispatcherHelper.getNegotiatedLocale().getLanguage());
+ DispatcherHelper.getNegotiatedLocale().getLanguage()).getName();
case 2:
return m_contact.getTitle();
-// case 2:
-// return (m_personEntry.getDescription() != null && m_personEntry.getDescription().length() > MAX_DESC_LENGTH)
-// ? m_personEntry.getDescription().substring(0, MAX_DESC_LENGTH)
-// : m_personEntry.getDescription();
case 3:
return GlobalizationUtil.globalize("cms.ui.delete").localize();
default:
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonPropertyForm.java
index 1d3404b86..29b4b1620 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonPropertyForm.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonPropertyForm.java
@@ -30,6 +30,7 @@ import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.DateParameter;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
@@ -107,6 +108,7 @@ public class GenericPersonPropertyForm extends BasicPageForm implements FormProc
form.add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize()));
ParameterModel surnameParam = new StringParameter(SURNAME);
+ surnameParam.addParameterListener(new NotNullValidationListener());
TextField surname = new TextField(surnameParam);
form.add(surname);
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java
index 45b864c09..a3c053618 100755
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java
@@ -173,7 +173,7 @@ public class LinkPropertyForm extends FormSection
add(m_targetURI);
add(new Label("Content Item:"));
- m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_contentType);
+ m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_itemModel.getContentType());
m_itemSearch.getSearchButton().setOnFocus("toggle_link_fields(true)");
m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)");
add(m_itemSearch);