BaseContact:

Nun ist BaseContact nicht mehr von Person abgeleitet. Stattdessen wird Person als component verwendet. Die Klassen enthalten die ersten grundlegenden Methoden.

git-svn-id: https://svn.libreccm.org/ccm/trunk@168 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2009-05-13 13:26:12 +00:00
parent e58cb3c93a
commit 0f780a23ba
11 changed files with 192 additions and 46 deletions

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-cms-types-baseContact"
prettyName="Red Hat CCM Content Types"
version="6.5.0"
release="1"
webapp="ROOT">
<ccm:dependencies>
<ccm:requires name="ccm-core" version="6.2.0" relation="ge"/>
<ccm:requires name="ccm-cms" version="6.2.0" relation="ge"/>
</ccm:dependencies>
<ccm:directories>
<ccm:directory name="pdl"/>
<ccm:directory name="sql"/>
<ccm:directory name="src"/>
</ccm:directories>
<ccm:contacts>
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
</ccm:contacts>
<ccm:description>
The BaseContact Content Type for the Red Hat CCM CMS.
</ccm:description>
</ccm:application>

View File

@ -1,13 +1,17 @@
model com.arsdigita.cms.contenttypes; model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contenttypes.Person; import com.arsdigita.cms.contenttypes.Person;
import com.arsdigita.cms.contenttypes.BaseAddress;
import com.arsdigita.cms.*; import com.arsdigita.cms.*;
// Contact Object // Contact Object
object type BaseContact extends Person { object type BaseContact extends ContentPage {
component BaseAddress [0..n] addresses = join ct_baseContacts.address_id componetn Person [0..1] person = join ct_baseContacts.person_id
to ct_baseAddresses.address_id; to ct_persons.person_id;
component BaseAddress [0..1] address = join ct_baseContacts.address_id
to ct_baseAddresses.address_id;
component BaseContactEntry [0..n] contactentries = join ct_baseContacts.contact_id component BaseContactEntry [0..n] contactentries = join ct_baseContacts.contact_id
to ct_baseContactEntries.contact_id; to ct_baseContactEntries.contact_id;

View File

@ -3,7 +3,8 @@
<table name="inits"/> <table name="inits"/>
<table name="acs_objects"/> <table name="acs_objects"/>
<table name="cms_items"/> <table name="cms_items"/>
<table name="ct_baseAdresses"/> <table name="ct_baseAddresses"/>
<table name="ct_persons"/>
<initializer class="com.arsdigita.cms.Initializer"/> <initializer class="com.arsdigita.cms.Initializer"/>
</requires> </requires>
<provides> <provides>

View File

@ -35,30 +35,33 @@ import java.math.BigDecimal;
public class BaseContact extends ContentPage { public class BaseContact extends ContentPage {
/** PDL property names */ /** PDL property names */
public static final String PERSON = "person";
public static final String ADDRESS = "address";
public static final String CONTACT_ENTRIES = "contactentries";
/** Data object type for tihs domain object */ /** Data object type for tihs domain object */
public static final String BASE_DATA_OBJECT_TYPE public static final String BASE_DATA_OBJECT_TYPE
= "com.arsdigita.cms.contenttypes.Organization"; = "com.arsdigita.cms.contenttypes.baseContact";
public BaseContact () { public BaseContact() {
super(BASE_DATA_OBJECT_TYPE); super(BASE_DATA_OBJECT_TYPE);
} }
public BaseContact ( BigDecimal id ) public BaseContact(BigDecimal id)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id)); this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
public BaseContact ( OID id ) public BaseContact(OID id)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
super(id); super(id);
} }
public BaseContact ( DataObject obj ) { public BaseContact(DataObject obj) {
super(obj); super(obj);
} }
public BaseContact ( String type ) { public BaseContact(String type) {
super(type); super(type);
} }
@ -72,46 +75,40 @@ public class BaseContact extends ContentPage {
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
// accessors // accessors
/* // Set the person for this contact
public String getLink () { public Person getPerson() {
return (String)get(LINK); return (Person) get(PERSON);
} }
public void setLink ( String link ) { // Get the person for this contact
set(LINK, link); public void setPerson(Person person) {
} set(PERSON, person);
*/
/*
public BigDecimal getImageID() {
return (BigDecimal)get(IMAGE_ID);
} }
public ImageAsset getImage() { // Get the address for this contact
DataObject obj = (DataObject)get(IMAGE); public BaseAddress getAddress() {
if ( obj == null ) { return (BaseAddress) get(ADDRESS);
return null;
}
return new ImageAsset(obj);
} }
public void setImage(ImageAsset image) { // Set the address for this contact
if (image != null) public void setAddress(BaseAddress address) {
image.setMaster(this); set(ADDRESS, address);
setAssociation(IMAGE,image);
} }
// Get all contact entries for this contact, p. ex. phone number, type of contact etc.
public void delete() { public BaseContactEntryCollection getContactEntries() {
ImageAsset image = getImage(); return new BaseContactEntryCollection ((DataCollection) get(CONTACT_ENTRIES));
if (image != null) { }
setAssociation(IMAGE, null);
save(); // Add a contact entry for this contact
image.delete(); public void addContactEntry(BaseContactEntry contactEntry) {
} Assert.exists(contactEntry, BaseContactEntry.class);
add(CONTACT_ENTRIES, contactEntry);
super.delete(); }
// Remove a contect entry for this contact
public void removeContactEntry(BaseContactEntry contactEntry) {
Assert.exists(contactEntry, BaseContactEntry.class);
remove(CONTACT_ENTRIES, contactEntry);
} }
*/
} }

View File

@ -0,0 +1,77 @@
/*
* BaseContactEntry.java
*
* Created on 13. Mai 2009, 12:31
*
* This class is part of BaseContact and stores the contact informations.
* These informations is organized by a key, which possible values are set by a config param.
* In addition there is a description field to provide additional information for this entry
* which will be shown along with the entry value, if set. If there is no description set, the
* key will be used as a fallback label.
*
* For example:
* key = "phone"
* description = "office phone"
* value = "1234 / 123456"
*
* would be shown as
* office phone: 1234 / 123456
*/
package com.arsdigita.cms.contenttypes;
/**
*
* @author quasi
*/
public class BaseContactEntry extends DomainObject {
private static final Logger s_log = Logger.getLogger(BaseContactEntry.class);
/** PDL property names */
public static final String KEY = "key";
public static final String VALUE = "value";
public static final String DESCRIPTION = "description";
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.BaseContactEntry";
/**
* Creates a new instance of BaseContactEntry
*/
public BaseContactEntry() {
}
/////////////////////////////////////////////////
// accessors
// Get key
public String getKey() {
return (String) get(KEY);
}
// Set key
public void setKey(String key) {
set(KEY, key);
}
// Get value
public String getValue() {
return (String) get(VALUE);
}
// Set value
public void setValue(String value) {
set(VALUE, value);
}
// Get description
public String getDescription() {
return (String) get(DESCRIPTION);
}
public void setDescription(String Description) {
set(DESCRIPTION, description);
}
}

View File

@ -0,0 +1,43 @@
/*
* BaseContactEntryCollection.java
*
* Created on 13. Mai 2009, 12:32
*
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataCollection;
import org.apache.log4j.Logger;
/**
*
* @author quasi
*/
public class BaseContactEntryCollection extends DomainCollection {
/**
* Creates a new instance of BaseContactEntryCollection
*/
public BaseContactEntryCollection() {
}
public final String getKey() {
return (String) getBaseContactEntry().getKey();
}
public final String getDescription() {
return (String) getBaseContactEntry().getDescription();
}
public final String getValue() {
return (String) getBaseContactEntry().getValue();
}
public BaseContactEntry getBaseContactEntry() {
return (BaseContactEntry) getDomainObject();
}
}