Verschiedene Korrekturen und Ergänzungen.

git-svn-id: https://svn.libreccm.org/ccm/trunk@579 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2010-10-17 18:10:58 +00:00
parent 19aa607371
commit 6d1f718384
15 changed files with 141 additions and 80 deletions

View File

@ -2,13 +2,13 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.cms;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.SessionManager;
import org.apache.log4j.Logger;
/**
*
@ -16,18 +16,21 @@ import com.arsdigita.persistence.SessionManager;
*/
public class RelationAttributeCollection extends DomainCollection {
public static final Logger logger =
Logger.getLogger(
RelationAttributeCollection.class);
public static String ATTRIBUTE = RelationAttribute.ATTRIBUTE;
public static String KEY = RelationAttribute.KEY;
public static String LANGUAGE = RelationAttribute.LANGUAGE;
public static String NAME = RelationAttribute.NAME;
public static String DESCRIPTION = RelationAttribute.DESCRIPTION;
private Filter m_attributeFilter = null;
private Filter m_keyFilter = null;
private Filter m_languageFilter = null;
public RelationAttributeCollection() {
super(SessionManager.getSession().retrieve(RelationAttribute.BASE_DATA_OBJECT_TYPE));
super(SessionManager.getSession().retrieve(
RelationAttribute.BASE_DATA_OBJECT_TYPE));
}
public RelationAttributeCollection(String attribute) {
@ -64,7 +67,7 @@ public class RelationAttributeCollection extends DomainCollection {
public boolean removeAttributeFilter(String attribute) {
boolean retVal = false;
retVal = this.removeFilter(m_attributeFilter);
if(retVal == true) {
if (retVal == true) {
m_attributeFilter = null;
}
return retVal;
@ -77,7 +80,7 @@ public class RelationAttributeCollection extends DomainCollection {
public boolean removeKeyFilter(String key) {
boolean retVal = false;
retVal = this.removeFilter(m_keyFilter);
if(retVal == true) {
if (retVal == true) {
m_keyFilter = null;
}
return retVal;
@ -90,7 +93,7 @@ public class RelationAttributeCollection extends DomainCollection {
public boolean removeLanguageFilter(String language) {
boolean retVal = false;
retVal = this.removeFilter(m_languageFilter);
if(retVal == true) {
if (retVal == true) {
m_languageFilter = null;
}
return retVal;
@ -114,8 +117,11 @@ public class RelationAttributeCollection extends DomainCollection {
// Get RelationAttribute in desired language
public RelationAttribute getRelationAttribute(String key, String language) {
logger.debug(String.format("this.getKey() = %s", this.getKey()));
logger.debug(String.format("this.language() = %s", this.getLanguage()));
// First, test the current element
if(this.getKey().equals(key) && this.getLanguage().equals(language)) {
if (this.getKey().equals(key) && this.getLanguage().equals(language)) {
return this.getRelationAttribute();
@ -123,8 +129,9 @@ public class RelationAttributeCollection extends DomainCollection {
// Rewind the collection and search for a matching element
this.rewind();
while(this.next()) {
if(this.getKey().equals(key) && this.getLanguage().equals(language)){
while (this.next()) {
if (this.getKey().equals(key) && this.getLanguage().equals(
language)) {
return this.getRelationAttribute();
}
}
@ -147,12 +154,11 @@ public class RelationAttributeCollection extends DomainCollection {
boolean retVal = false;
this.addLanguageFilter(language);
if(this.size() > 0) {
if (this.size() > 0) {
retVal = true;
}
this.removeLanguageFilter(language);
return retVal;
}
}

View File

@ -109,3 +109,7 @@ cms.contenttypes.ui.orgaunit.departments=Departments
cms.contenttypes.ui.orgaunit.persons=Persons
cms.contenttypes.ui.genericorgaunit.title=Name
cms.contenttypes.ui.genericorgaunit.addendum=Addendum
cms.contenttypes.ui.genericorgaunit.select_person=Select person
cms.contenttypes.ui.contact.contactEntry.none=No contact information yet
cms.contenttypes.ui.genericorgaunit.person.role=Role
cms.ui.delete=Remove

View File

@ -112,3 +112,6 @@ cms.contenttypes.ui.orgaunit.departments=Untergeordnete Organizationseinheiten
cms.contenttypes.ui.orgaunit.persons=Personen
cms.contenttypes.ui.genericorgaunit.title=Name
cms.contenttypes.ui.genericorgaunit.addendum=Zusatz
cms.contenttypes.ui.genericorgaunit.select_person=Person ausw\u00e4hlen
cms.contenttypes.ui.genericorgaunit.person.role=Rolle
cms.ui.delete=Entfernen

View File

@ -47,7 +47,6 @@ public class GenericOrganizationalUnit extends ContentPage {
public final static String CONTACT_ORDER = "contact_order";
public final static String PERSONS = "persons";
public final static String ROLE = "role_name";
public final static String PERSON_ORDER = "person_order";
public final static String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.GenericOrganizationalUnit";
@ -92,7 +91,7 @@ public class GenericOrganizationalUnit extends ContentPage {
DataObject link = add(CONTACTS, contact);
link.set(CONTACT_TYPE, contactType);
link.set(CONTACT_ORDER, BigDecimal.valueOf(getContacts().size()));
link.set(CONTACT_ORDER, Integer.valueOf((int)getContacts().size()));
}
public void removeContact(GenericContact contact) {

View File

@ -67,7 +67,8 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm {
protected void addWidgets() {
add(new Label((String) ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact").localize()));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType(GenericContact.class.getName()));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(GenericContact.class.getName()));
add(m_itemSearch);
add(new Label(ContenttypesGlobalizationUtil.globalize(
@ -76,9 +77,11 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm {
GenericOrganizationalUnitContactCollection.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
GenericContactTypeCollection contacttypes = new GenericContactTypeCollection();
GenericContactTypeCollection contacttypes =
new GenericContactTypeCollection();
contacttypes.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
@ -87,15 +90,11 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm {
contactType.addOption(new Option(ct.getKey(), ct.getName()));
}
//Only for testing
contactType.addOption(new Option("commonContact", "Common Contact"));
add(contactType);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
setVisible(state, true);
@ -108,10 +107,12 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm {
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
if (!(this.getSaveCancelSection().getCancelButton().isSelected(state))) {
orgaunit.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
orgaunit.addContact((GenericContact) data.get(ITEM_SEARCH),
(String) data.get(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
}
init(fse);
//init(fse);
}
}

View File

@ -126,11 +126,10 @@ public class GenericOrganizationalUnitContactTable extends Table implements
private class GenericOrganizationalUnitTableModel implements TableModel {
private final int MAX_DESC_LENGTH = 25;
private Table m_table;
private GenericOrganizationalUnitContactCollection m_contactCollection;
private GenericContact m_contact;
private GenericContactTypeCollection contacttypes =
private GenericContactTypeCollection m_contacttypes =
new GenericContactTypeCollection();
private GenericOrganizationalUnitTableModel(
@ -160,12 +159,14 @@ public class GenericOrganizationalUnitContactTable extends Table implements
}
public Object getElementAt(int columnIndex) {
s_log.debug(String.format("contacttypes.size() = %d",
m_contacttypes.size()));
switch (columnIndex) {
case 0:
return contacttypes.getRelationAttribute(m_contactCollection.
getContactType(),
DispatcherHelper.
getNegotiatedLocale().getLanguage());
return m_contacttypes.getRelationAttribute(
m_contactCollection.getContactType(),
DispatcherHelper.getNegotiatedLocale().
getLanguage());
case 1:
return m_contact.getTitle();
case 2:
@ -311,17 +312,16 @@ public class GenericOrganizationalUnitContactTable extends Table implements
getSelectedObject(state);
GenericOrganizationalUnitContactCollection contacts =
orgaunit.getContacts();
orgaunit.getContacts();
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
}
else if(column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
orgaunit.removeContact(contact);
} else if(column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
} else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
contacts.swapWithPrevious(contact);
} else if(column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
contacts.swapWithNext(contact);
}

View File

@ -39,7 +39,6 @@ import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
@ -104,14 +103,14 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
GenericOrganizationalUnit orgaunit =
(GenericOrganizationalUnit) m_itemModel.
getSelectedObject(state);
return new GenericOrganizationalUnitTableModel(table, state,
return new GenericOrganizationalUnitTableModel(table,
state,
orgaunit);
}
}
private class GenericOrganizationalUnitTableModel implements TableModel {
private final int MAX_DESC_LENGTH = 25;
private Table m_table;
private GenericOrganizationalUnitPersonCollection m_personsCollection;
private GenericPerson m_person;
@ -150,16 +149,13 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
RelationAttributeCollection role = new RelationAttributeCollection(
getRoleAttributeName(),
m_personsCollection.getRoleName());
role.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage());
//return m_personsCollection.getRoleName();
if (role.next()) {
return role.getName();
} else {
return GlobalizationUtil.globalize("cms.ui.unknownRole");
return ContenttypesGlobalizationUtil.globalize("cms.ui.unknownRole");
}
case 2:
return GlobalizationUtil.globalize("cms.ui.delete").localize();
return ContenttypesGlobalizationUtil.globalize("cms.ui.delete").localize();
default:
return null;
}

View File

@ -26,6 +26,7 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import java.util.Date;
import org.apache.log4j.Logger;
/**
* <p>
@ -78,9 +79,9 @@ public class SciProject extends GenericOrganizationalUnit {
public static final String DEPARTMENTS_ORDER = "department";
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.SciProject";
private static final SciOrganizationConfig s_config =
new SciOrganizationConfig();
new SciOrganizationConfig();
private static final Logger logger = Logger.getLogger(SciProject.class);
static {
s_config.load();
@ -167,6 +168,8 @@ public class SciProject extends GenericOrganizationalUnit {
public void removeSubProject(SciProject project) {
Assert.exists(project, SciProject.class);
logger.debug(String.format("Removing subproject %s",
project.getTitle()));
remove(SUBPROJECTS, project);
}
@ -228,10 +231,14 @@ public class SciProject extends GenericOrganizationalUnit {
collection = (DataCollection) get(SUPER_PROJECT);
if (0 == collection.size()) {
logger.debug(String.format("Project %s has NO super project...",
getTitle()));
return null;
} else {
DataObject dobj;
logger.debug(String.format("Project %s has a super project...",
getTitle()));
collection.next();
dobj = collection.getDataObject();
@ -243,11 +250,19 @@ public class SciProject extends GenericOrganizationalUnit {
SciProject oldSuperProject;
oldSuperProject = getSuperProject();
remove(SUPER_PROJECT, oldSuperProject);
if (oldSuperProject != null) {
logger.debug("Removing old super project...");
remove(SUPER_PROJECT, oldSuperProject);
}
if (null != superProject) {
if (superProject != null) {
Assert.exists(superProject, SciProject.class);
add(SUPER_PROJECT, superProject);
logger.debug("Setting new super project...");
DataObject link = add(SUPER_PROJECT, superProject);
link.set(SUBPROJECT_ORDER,
Integer.valueOf((int) superProject.getSubProjects().size()));
link.save();
}
}
}

View File

@ -55,7 +55,7 @@ public class SciMemberPropertiesStep extends SimpleEditStep {
member = (SciMember) obj;
if (member.isAssociatedMember()) {
if ((member.isAssociatedMember() != null) && member.isAssociatedMember()) {
return (String) SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.member.yes").localize();
} else {
@ -74,7 +74,7 @@ public class SciMemberPropertiesStep extends SimpleEditStep {
member = (SciMember) obj;
if (member.isFormerMember()) {
if ((member.isFormerMember() != null) && member.isFormerMember()) {
return (String) SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.member.yes").localize();
} else {

View File

@ -94,10 +94,11 @@ public class SciMemberPropertyForm
FormData data = fse.getFormData();
SciMember member = (SciMember) super.initBasicWidgets(fse);
if (member.isAssociatedMember()) {
if ((member.isAssociatedMember() != null) &&
member.isAssociatedMember()) {
m_associated.setValue(fse.getPageState(), "assoc");
}
if (member.isFormerMember()) {
if ((member.isFormerMember() != null) && member.isFormerMember()) {
m_former.setValue(fse.getPageState(), "former");
}
}

View File

@ -130,3 +130,7 @@ sciorganization.ui.project.organizations=Involved organizations
sciorganization.ui.project.departments=Involved departments
sciorganization.ui.project.publications=Publications of the project
sciorganization.ui.project_description.title=Description
sciorganization.ui.project.add_member\ =Add member
sciorganization.ui.project.subproject..confirm_remove=Are you sure to remove this subproject?
sciorganization.ui.project.superproject..confirm_remove=Are you sure to remove the superior project?
sciorganization.ui.project.add_member=Add member

View File

@ -56,7 +56,7 @@ sciorganization.ui.department.subdepartment.confirm_remove=Wollen sie diese Unte
sciorganizations.ui.department.shortdescription=Kurzbeschreibung
sciorganizations.ui.organization.shortdescription=Kurzbeschreibung
sciorganization.ui.department.select_subdepartment=Unterabteilung zum hinzuf\u00fcgen ausw\u00e4hlen
sciorganization.ui.department.add_member=Mitglied ausw\u00e4hlen
sciorganization.ui.department.add_member=Mitglied hinzuf\u00fcgen
sciorganizations.ui.project.shortdesc=Kurzbeschreibung
sciorganization.ui.project.addDepartment=Beteiligte Abteilung hinzuf\u00fcgen
sciorganization.ui.project.addOrga=Beteiligte Organization hinzuf\u00fcgen
@ -76,7 +76,7 @@ sciorganization.ui.project.select_department=Abteilung zum hinzuf\u00fcgen ausw\
sciorganization.ui.project.superproject_none=Kein \u00fcbergeordnetes Projekt gefunden
sciorganization.ui.project.superproject=\u00dcbergeordnetes Projekt
sciorganization.ui.project.superproject.remove=\u00dcbergeordnetes Projekt entfernen
sciorganization.ui.project.superproject.confirm_remove=Wollen sie dieses \u00fcbergeordnete projekt wirklich entfernen?
sciorganization.ui.project.superproject.confirm_remove=Wollen sie dieses \u00fcbergeordnete Projekt wirklich entfernen?
sciorganization.ui.department.select_superdepartment=\u00dcbergeordnete Abteilung
sciorganization.ui.project.setSuperProject=\u00dcbergeordnetes Projekt setzen
sciorganization.ui.project.description.upload=Projektbeschreibung hochladen
@ -130,3 +130,7 @@ sciorganization.ui.project.organizations=Beteiligte Organisationen
sciorganization.ui.project.departments=Beteiligte Abteilungen
sciorganization.ui.project.publications=Publikationen des Projektes
sciorganization.ui.project_description.title=Beschreibung
sciorganization.ui.project.add_member\ =Mitglied hinzuf\u00fcgen
sciorganization.ui.project.subproject..confirm_remove=Sind sie sicher das sie dieses Unterprojekt entfernen wollen?
sciorganization.ui.project.superproject..confirm_remove=Wollen sie dieses \u00fcbergeordnete Projekt wirklich entfernen?
sciorganization.ui.project.add_member=Mitglied hinzuf\u00fcgen

View File

@ -49,11 +49,11 @@ public class SciProjectMemberStep extends SimpleEditStep {
new SciProjectMemberAddForm(itemModel);
add(ADD_MEMBER_SHEET_NAME,
(String) SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.department.add_member").localize(),
"sciorganization.ui.project.add_member").localize(),
new WorkflowLockedComponentAccess(addMemberSheet, itemModel),
addMemberSheet.getSaveCancelSection().getCancelButton());
GenericOrganizationalUnitPersonsTable memberTable = new GenericOrganizationalUnitPersonsTable(
SciProjectMemberTable memberTable = new SciProjectMemberTable(
itemModel);
setDisplayComponent(memberTable);
}

View File

@ -100,35 +100,41 @@ public class SciProjectPropertiesStep
if (!config.getProjectAddContactHide()) {
addStep(new GenericOrganizationalUnitContactPropertiesStep(itemModel,
parent),
SciOrganizationGlobalizationUtil.globalize("sciorganization.ui.project.contacts"));
SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.contacts"));
}
if (!config.getProjectAddPersonHide()) {
addStep(new SciProjectMemberStep(itemModel,
parent),
SciOrganizationGlobalizationUtil.globalize("sciorganization.ui.project.members"));
SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.members"));
}
if (!config.getProjectSetSuperProjectHide()) {
addStep(new SciProjectSuperProjectStep(itemModel,
parent),
SciOrganizationGlobalizationUtil.globalize("sciorganization.ui.project.superproject"));
SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.superproject"));
}
if (!config.getProjectAddSubProjectHide()) {
addStep(new SciProjectSubprojectsStep(itemModel,
parent),
SciOrganizationGlobalizationUtil.globalize("sciorganization.ui.project.subprojects"));
SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.subprojects"));
}
if (!config.getProjectAddOrganizationHide()) {
addStep(new SciProjectOrganizationsStep(itemModel, parent),
SciOrganizationGlobalizationUtil.globalize("sciorganization.ui.project.organizations"));
SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.organizations"));
}
if (!config.getProjectAddDepartmentHide()) {
addStep(new SciProjectDepartmentsStep(itemModel, parent),
SciOrganizationGlobalizationUtil.globalize( "sciorganization.ui.project.departments"));
SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.departments"));
}
if ((!config.getProjectMaterialsHide())

View File

@ -37,6 +37,7 @@ import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.util.LockableImpl;
import org.apache.log4j.Logger;
/**
* Sheet for showing the superior project of a {@link SciProject}.
@ -47,6 +48,8 @@ public class SciProjectSuperProjectSheet
extends Table
implements TableActionListener {
private static final Logger logger = Logger.getLogger(
SciProjectSuperProjectSheet.class);
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private ItemSelectionModel m_itemModel;
@ -106,12 +109,21 @@ public class SciProjectSuperProjectSheet
private Table m_table;
private SciProject m_superProject;
private boolean m_done;
public SciProjectSuperProjectSheetModel(Table table,
PageState state,
SciProject project) {
m_table = table;
m_superProject = project.getSuperProject();
if (m_superProject == null) {
m_done = false;
} else {
m_done = true;
logger.debug(String.format("Super project to show: %s", m_superProject.
getTitle()));
}
}
public int getColumnCount() {
@ -121,11 +133,19 @@ public class SciProjectSuperProjectSheet
public boolean nextRow() {
boolean ret;
if (null == m_superProject) {
ret = false;
/*if (m_superProject == null) {
ret = false;
} else {
ret = true;
m_superProject = null;
}*/
if (m_done) {
logger.debug("Returning true for nextRow()");
ret = true;
m_superProject = null;
m_done = false;
} else {
logger.debug("Returning false for nextRow()");
ret = false;
}
return ret;
@ -134,10 +154,12 @@ public class SciProjectSuperProjectSheet
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
logger.debug("returning project title...");
return m_superProject.getTitle();
case 1:
return SciOrganizationGlobalizationUtil.globalize(
"sciorganization.ui.project.superproject.remove");
"sciorganization.ui.project.superproject.remove").
localize();
default:
return null;
}
@ -207,7 +229,7 @@ public class SciProjectSuperProjectSheet
PageState state = event.getPageState();
/*SciProject superProject = new SciProject(
new BigDecimal(event.getRowKey().toString()));*/
new BigDecimal(event.getRowKey().toString()));*/
SciProject project = (SciProject) m_itemModel.getSelectedObject(state);