From 43456985789281ecb1ad97c5775bb199055367ab Mon Sep 17 00:00:00 2001 From: jensp Date: Mon, 18 Apr 2011 20:19:34 +0000 Subject: [PATCH] - Fixes am DaBInImporter - Unknown internationalisiert git-svn-id: https://svn.libreccm.org/ccm/trunk@865 8810af33-2d31-482b-a856-94f89814c4df --- .../arsdigita/cms/dabin/DaBInImporter.java | 229 +++++++++++++----- .../toolbox/ui/DomainObjectPropertySheet.java | 3 +- .../toolbox/ui/ToolboxResources.properties | 1 + .../toolbox/ui/ToolboxResources_de.properties | 1 + .../toolbox/ui/ToolboxResources_fr.properties | 3 +- .../ui/PublicationPropertiesStep.java | 13 +- 6 files changed, 190 insertions(+), 60 deletions(-) diff --git a/ccm-cms-dabinimporter/src/com/arsdigita/cms/dabin/DaBInImporter.java b/ccm-cms-dabinimporter/src/com/arsdigita/cms/dabin/DaBInImporter.java index 39679b4af..7888f23f9 100644 --- a/ccm-cms-dabinimporter/src/com/arsdigita/cms/dabin/DaBInImporter.java +++ b/ccm-cms-dabinimporter/src/com/arsdigita/cms/dabin/DaBInImporter.java @@ -132,8 +132,12 @@ public class DaBInImporter extends Program { private SciOrganization orgaDe; private SciOrganization orgaEn; private ContentBundle orga; - private Address postalAddress; - private Address officeAddress; + private ContentBundle postalAddress; + private Address postalAddressDe; + private Address postalAddressEn; + private ContentBundle officeAddress; + private Address officeAddressDe; + private Address officeAddressEn; private Domain termsDomain; private Term publicationsTerm; private Term workingPapersTerm; @@ -333,113 +337,228 @@ public class DaBInImporter extends Program { orgaDe.setTitle(config.getProperty("orga.title.de")); orgaDe.setContentSection(section); orgaDe.setLanguage("de"); - orgaDe.save(); + orgaDe.setLifecycle(createLifecycle(lifecycle)); orgaDe.setContentSection(section); + orgaDe.save(); orgaEn = new SciOrganization(); orgaEn.setName(config.getProperty("orga.name.en")); orgaEn.setTitle(config.getProperty("orga.title.en")); orgaEn.setContentSection(section); orgaEn.setLanguage("en"); - orgaEn.save(); + orgaEn.setLifecycle(createLifecycle(lifecycle)); orgaEn.setContentSection(section); + orgaEn.save(); ContentBundle orga = new ContentBundle(orgaDe); orga.addInstance(orgaEn); + orga.setLifecycle(createLifecycle(lifecycle)); + orga.setContentSection(section); organization.addItem(orga); + orgaDe.setContentSection(section); + orgaEn.setContentSection(section); + if (config.getProperty("orga.address.postal.name") != null) { - postalAddress = new Address(); - postalAddress.setName(config.getProperty( + postalAddressDe = new Address(); + postalAddressDe.setName(config.getProperty( "orga.address.postal.name")); - postalAddress.setTitle(config.getProperty( + postalAddressDe.setTitle(config.getProperty( "orga.address.postal.title")); - postalAddress.setAddress(config.getProperty( + postalAddressDe.setAddress(config.getProperty( "orga.address.postal.data"). trim(). replace("\t", ""). replaceAll(" +", " "). replace("\n ", "\n")); - postalAddress.setPostalCode(config.getProperty( + postalAddressDe.setPostalCode(config.getProperty( "orga.address.postal.code")); - postalAddress.setCity(config.getProperty( + postalAddressDe.setCity(config.getProperty( "orga.address.postal.city")); - postalAddress.setState(config.getProperty( + postalAddressDe.setState(config.getProperty( "orga.address.postal.state")); - postalAddress.setIsoCountryCode(config.getProperty( + postalAddressDe.setIsoCountryCode(config.getProperty( "orga.address.postal.country")); - postalAddress.setContentSection(section); - postalAddress.setLanguage("de"); - postalAddress.save(); + postalAddressDe.setLanguage("de"); + postalAddressDe.setLifecycle(createLifecycle(lifecycle)); + postalAddressDe.setContentSection(section); + postalAddressDe.save(); - ContentBundle bundle = new ContentBundle(postalAddress); - organization.addItem(bundle); - - Contact contact = new Contact(); - contact.setName(config.getProperty( + postalAddressEn = new Address(); + postalAddressEn.setName(config.getProperty( "orga.address.postal.name")); - contact.setTitle(config.getProperty( + postalAddressEn.setTitle(config.getProperty( "orga.address.postal.title")); - contact.setAddress(postalAddress); - contact.setLanguage("de"); - contact.save(); - bundle = new ContentBundle(contact); - organization.addItem(bundle); + postalAddressEn.setAddress(config.getProperty( + "orga.address.postal.data"). + trim(). + replace("\t", ""). + replaceAll(" +", " "). + replace("\n ", "\n")); + postalAddressEn.setPostalCode(config.getProperty( + "orga.address.postal.code")); + postalAddressEn.setCity(config.getProperty( + "orga.address.postal.city")); + postalAddressEn.setState(config.getProperty( + "orga.address.postal.state")); + postalAddressEn.setIsoCountryCode(config.getProperty( + "orga.address.postal.country")); + postalAddressEn.setLanguage("en"); + postalAddressEn.setLifecycle(createLifecycle(lifecycle)); + postalAddressEn.setContentSection(section); + postalAddressEn.save(); - orgaDe.addContact(contact, "postalAddress"); + postalAddress = new ContentBundle(postalAddressDe); + postalAddress.addInstance(postalAddressEn); + postalAddress.setLifecycle(createLifecycle(lifecycle)); + postalAddress.setContentSection(section); + organization.addItem(postalAddress); + + postalAddressDe.setContentSection(section); + postalAddressEn.setContentSection(section); + + Contact contactDe = new Contact(); + contactDe.setName(config.getProperty( + "orga.address.postal.name")); + contactDe.setTitle(config.getProperty( + "orga.address.postal.title")); + contactDe.setAddress((Address) postalAddress. + getPrimaryInstance()); + contactDe.setLanguage("de"); + contactDe.setLifecycle(createLifecycle(lifecycle)); + contactDe.setContentSection(section); + contactDe.save(); + + Contact contactEn = new Contact(); + contactEn.setName(config.getProperty( + "orga.address.postal.name")); + contactEn.setTitle(config.getProperty( + "orga.address.postal.title")); + contactEn.setAddress((Address) postalAddress. + getPrimaryInstance()); + contactEn.setLanguage("en"); + contactEn.setLifecycle(createLifecycle(lifecycle)); + contactEn.setContentSection(section); + contactEn.save(); + + ContentBundle contact = new ContentBundle(contactDe); + contact.addInstance(contactEn); + contact.setLifecycle(createLifecycle(lifecycle)); + contact.setContentSection(section); + organization.addItem(contact); + + contactDe.setContentSection(section); + contactEn.setContentSection(section); + + orgaDe.addContact((Contact) contact.getPrimaryInstance(), + "postalAddress"); orgaDe.save(); - orgaEn.addContact(contact, "postalAddress"); + orgaEn.addContact((Contact) contact.getPrimaryInstance(), + "postalAddress"); orgaEn.save(); } if (config.getProperty("orga.address.office.name") != null) { - officeAddress = new Address(); - officeAddress.setName(config.getProperty( + officeAddressDe = new Address(); + officeAddressDe.setName(config.getProperty( "orga.address.office.name")); - officeAddress.setTitle(config.getProperty( + officeAddressDe.setTitle(config.getProperty( "orga.address.office.title")); - officeAddress.setAddress(config.getProperty( + officeAddressDe.setAddress(config.getProperty( "orga.address.office.data"). trim(). replace("\t", ""). replaceAll(" +", " "). replace("\n ", "\n")); //.replace("\n ", "\n")); - officeAddress.setPostalCode(config.getProperty( + officeAddressDe.setPostalCode(config.getProperty( "orga.address.office.code")); - officeAddress.setCity(config.getProperty( + officeAddressDe.setCity(config.getProperty( "orga.address.office.city")); - officeAddress.setState(config.getProperty( + officeAddressDe.setState(config.getProperty( "orga.address.office.state")); - officeAddress.setIsoCountryCode(config.getProperty( + officeAddressDe.setIsoCountryCode(config.getProperty( "orga.address.office.country")); - officeAddress.setContentSection(section); - officeAddress.setLanguage("de"); - officeAddress.save(); + officeAddressDe.setLanguage("de"); + officeAddressDe.setLifecycle(createLifecycle(lifecycle)); + officeAddressDe.setContentSection(section); + officeAddressDe.save(); - ContentBundle bundle = new ContentBundle(officeAddress); - organization.addItem(bundle); - - Contact contact = new Contact(); - contact.setName(config.getProperty( + officeAddressEn = new Address(); + officeAddressEn.setName(config.getProperty( "orga.address.office.name")); - contact.setTitle(config.getProperty( + officeAddressEn.setTitle(config.getProperty( "orga.address.office.title")); - contact.setAddress(officeAddress); - contact.setLanguage("de"); + officeAddressEn.setAddress(config.getProperty( + "orga.address.office.data"). + trim(). + replace("\t", ""). + replaceAll(" +", " "). + replace("\n ", "\n")); + //.replace("\n ", "\n")); + officeAddressEn.setPostalCode(config.getProperty( + "orga.address.office.code")); + officeAddressEn.setCity(config.getProperty( + "orga.address.office.city")); + officeAddressEn.setState(config.getProperty( + "orga.address.office.state")); + officeAddressEn.setIsoCountryCode(config.getProperty( + "orga.address.office.country")); + officeAddressEn.setLanguage("en"); + officeAddressEn.setLifecycle(createLifecycle(lifecycle)); + officeAddressEn.setContentSection(section); + officeAddressEn.save(); + + officeAddress = new ContentBundle(officeAddressDe); + officeAddress.setLifecycle(createLifecycle(lifecycle)); + officeAddress.setContentSection(section); + officeAddress.addInstance(officeAddressEn); + organization.addItem(officeAddress); + + officeAddressDe.setContentSection(section); + officeAddressEn.setContentSection(section); + + Contact contactDe = new Contact(); + contactDe.setName(config.getProperty( + "orga.address.office.name")); + contactDe.setTitle(config.getProperty( + "orga.address.office.title")); + contactDe.setAddress((Address) officeAddress. + getPrimaryInstance()); + contactDe.setLanguage("de"); + contactDe.setLifecycle(createLifecycle(lifecycle)); + contactDe.setContentSection(section); + contactDe.save(); + + Contact contactEn = new Contact(); + contactEn.setName(config.getProperty( + "orga.address.office.name")); + contactEn.setTitle(config.getProperty( + "orga.address.office.title")); + contactEn.setAddress((Address) officeAddress. + getPrimaryInstance()); + contactEn.setLanguage("en"); + contactEn.setLifecycle(createLifecycle(lifecycle)); + contactEn.setContentSection(section); + contactEn.save(); + + ContentBundle contact = new ContentBundle(contactDe); + contact.addInstance(contactEn); + contact.setLifecycle(createLifecycle(lifecycle)); contact.setContentSection(section); - contact.save(); - bundle = new ContentBundle(contact); - organization.addItem(bundle); + organization.addItem(contact); - orgaDe.addContact(contact, "officeAddress"); + contactDe.setContentSection(section); + contactEn.setContentSection(section); + + orgaDe.addContact((Contact) contact.getPrimaryInstance(), + "officeAddress"); orgaDe.save(); - orgaEn.addContact(contact, "officeAddress"); + orgaEn.addContact((Contact) contact.getPrimaryInstance(), + "officeAddress"); orgaEn.save(); + // orga.setContentSection(section); - orgaDe.setContentSection(section); - orgaEn.setContentSection(section); - orga.setContentSection(section); } } }; diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java b/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java index d7b826da2..95fce100d 100755 --- a/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java +++ b/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java @@ -37,6 +37,7 @@ import com.arsdigita.kernel.ui.DomainObjectSelectionModel; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.toolbox.util.GlobalizationUtil; + /** * Displays a list of label-value pairs, which represent the attributes * of a domain object. @@ -315,7 +316,7 @@ public class DomainObjectPropertySheet extends PropertySheet { private String m_default; public DefaultAttributeFormatter() { - this("unknown"); + this((String)GlobalizationUtil.globalize("cms.ui.unknown").localize()); } public DefaultAttributeFormatter(String def) { diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties index 76b69bf6d..01f000eae 100755 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties +++ b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties @@ -1,2 +1,3 @@ toolbox.ui.na=N/A toolbox.ui.no_results=No Results. +cms.ui.unknown=unknown diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties index c8689ae7b..22b9c790c 100644 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties +++ b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties @@ -1,2 +1,3 @@ toolbox.ui.na=N/A toolbox.ui.no_results=Keine Ergebnisse. +cms.ui.unknown=unbekannt diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties index 9c26a2987..c64eaeb26 100755 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties +++ b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties @@ -1,2 +1,3 @@ toolbox.ui.na=N/A -toolbox.ui.no_results=Pas de résultats +toolbox.ui.no_results=Pas de r\u00e9sultats +cms.ui.unknown= diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java index 7b6a43213..77d74f3b2 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java @@ -23,6 +23,7 @@ import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SegmentedPanel; +import com.arsdigita.cms.CMSGlobalized; import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; @@ -33,6 +34,7 @@ import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainService; import java.text.DateFormat; @@ -146,7 +148,7 @@ public class PublicationPropertiesStep extends SimpleEditStep { step); } - protected static class PreFormattedTextFormatter + protected static class PreFormattedTextFormatter extends DomainService implements DomainObjectPropertySheet.AttributeFormatter { @@ -155,8 +157,13 @@ public class PublicationPropertiesStep extends SimpleEditStep { } public String format(DomainObject obj, String attribute, PageState state) { - return String.format("
%s
", get(obj, attribute)); + String str = (String) get(obj, attribute); + if ((str == null) || str.trim().isEmpty()) { + return (String) GlobalizationUtil.globalize("cms.ui.unknown"). + localize(); + } else { + return String.format("
%s
", str); + } } } - }