Aktueller Stand ZeSLanguageVersionFix
git-svn-id: https://svn.libreccm.org/ccm/trunk@994 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
846ffb736d
commit
32ac96e4ef
|
|
@ -56,7 +56,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
private TabbedPane m_tabbedPane;
|
||||
private ItemSearchBrowsePane m_browse;
|
||||
private ItemSearchPopup m_search;
|
||||
private ItemSearchCreateItemPane m_create;
|
||||
//private ItemSearchCreateItemPane m_create;
|
||||
private BigDecimalParameter m_sectionId;
|
||||
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
||||
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ class DataObjectImpl implements DataObject {
|
|||
}
|
||||
|
||||
private com.redhat.persistence.metadata.Property convert(String property) {
|
||||
System.out.printf("\n!!!Converting property '%s'...\n", property);
|
||||
return C.prop(m_ssn.getRoot(), getObjectType().getProperty(property));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,17 @@ import com.arsdigita.cms.ContentItem;
|
|||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentSectionCollection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.ContentTypeWorkflowTemplate;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.Folder.ItemCollection;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.workflow.simple.Workflow;
|
||||
import com.arsdigita.workflow.simple.WorkflowTemplate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -44,6 +49,48 @@ public class ZeSLanguageVersionFix {
|
|||
}
|
||||
}
|
||||
|
||||
fixZeS(session, sectionContent, sectionResearch);
|
||||
fixTheorieUndVerfassung(session, sectionContent, sectionResearch);
|
||||
fixInstitutionenUndGeschichte(session,
|
||||
sectionContent,
|
||||
sectionResearch);
|
||||
fixWirtschaftswissenschaftliche(session,
|
||||
sectionContent,
|
||||
sectionResearch);
|
||||
fixGesundheit(session, sectionContent, sectionResearch);
|
||||
fixGesundheitArbeitsbereich1(session,
|
||||
sectionContent,
|
||||
sectionResearch);
|
||||
fixGesundheitArbeitsbereich2(session,
|
||||
sectionContent,
|
||||
sectionResearch);
|
||||
fixGesundheitArbeitsbereich3(session,
|
||||
sectionContent,
|
||||
sectionResearch);
|
||||
fixGesundheitArbeitsbereich4(session,
|
||||
sectionContent,
|
||||
sectionResearch);
|
||||
fixGeschlechterpolitik(session, sectionContent, sectionResearch);
|
||||
|
||||
fixFileStorageItems(session, sectionContent, sectionResearch);
|
||||
|
||||
System.out.println("Finished, commiting transaction...");
|
||||
tctx.commitTxn();
|
||||
} catch (Exception ex) {
|
||||
System.err.println(
|
||||
"Exeception ocurred during convert process. "
|
||||
+ "Transaction rolled back, all changes will be lost.");
|
||||
ex.printStackTrace(System.err);
|
||||
} finally {
|
||||
if (tctx.inTxn()) {
|
||||
tctx.abortTxn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void fixZeS(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
System.out.println(
|
||||
"First, the publications of the english variant of the ZeS...");
|
||||
Folder folder = sectionContent.getRootFolder();
|
||||
|
|
@ -60,20 +107,120 @@ public class ZeSLanguageVersionFix {
|
|||
zesDe = (SciOrganizationWithPublications) ((ContentPage) item).
|
||||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
zesEn = (SciOrganizationWithPublications) zesDe.getContentBundle().getInstance("en");
|
||||
SciOrganizationPublicationsCollection zesPublications = zesDe.getPublications();
|
||||
while(zesPublications.next()) {
|
||||
Publication publicationDe = (Publication) zesPublications.getPublication().getContentBundle().getPrimaryInstance();
|
||||
if (publicationDe.getContentBundle().getInstance("en") == null) {
|
||||
//craete en variant of publication...
|
||||
}
|
||||
Publication publicationEn = (Publication) publicationDe.getContentBundle().getInstance("en");
|
||||
zesEn.addPublication(publicationEn);
|
||||
}
|
||||
zesEn = (SciOrganizationWithPublications) zesDe.getContentBundle().
|
||||
getInstance("en");
|
||||
|
||||
System.out.printf("Got the ZeS: %s (%s)\n", zesDe.getName(), zesDe.
|
||||
getLanguage());
|
||||
|
||||
SciOrganizationPublicationsCollection publicationsZeSde = zesDe.
|
||||
getPublications();
|
||||
SciOrganizationPublicationsCollection publicationsZeSen = zesEn.
|
||||
getPublications();
|
||||
|
||||
Publication publicationDe;
|
||||
Publication publicationEn;
|
||||
|
||||
//Delete all publication links from the english variant to german variants of publications
|
||||
System.out.println(
|
||||
"Deleting all assciations of the english ZeS item with german variants of publication items...");
|
||||
int i = 1;
|
||||
long size = publicationsZeSen.size();
|
||||
while (publicationsZeSen.next()) {
|
||||
publicationEn = publicationsZeSen.getPublication();
|
||||
System.out.printf("\tProcessing item %d of %d ('%s')...\n",
|
||||
i,
|
||||
size,
|
||||
publicationEn.getName());
|
||||
if (!("de").equals(publicationEn.getLanguage())) {
|
||||
zesEn.removePublication(publicationEn);
|
||||
LifecycleDefinition lifecycleDef =
|
||||
ContentTypeLifecycleDefinition.
|
||||
getLifecycleDefinition(
|
||||
publicationEn.getContentSection(),
|
||||
publicationEn.getContentType());
|
||||
|
||||
System.out.println("\t\t\tPublishing new item...");
|
||||
publicationEn.publish(lifecycleDef, new Date());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
publicationEn = null;
|
||||
|
||||
publicationsZeSen = zesEn.getPublications();
|
||||
|
||||
i = 1;
|
||||
size = publicationsZeSde.size();
|
||||
System.out.println(
|
||||
"Processing publications and linking them to the english variant of the ZeS item...");
|
||||
while (publicationsZeSde.next()) {
|
||||
publicationDe = publicationsZeSde.getPublication();
|
||||
publicationEn = (Publication) publicationDe.getContentBundle().
|
||||
getInstance("en");
|
||||
System.out.printf("\tProceesing item %d of %d ('%s')...",
|
||||
i,
|
||||
size,
|
||||
publicationDe.getName());
|
||||
|
||||
System.out.println(
|
||||
"\tCreating english versions of the publication items of associated with the ZeS item (if necessary)...");
|
||||
if (publicationEn == null) {
|
||||
System.out.println(
|
||||
"\t\tNo english version found, creating one...");
|
||||
publicationEn =
|
||||
(Publication) createEnglishVersion(publicationDe,
|
||||
sectionResearch);
|
||||
} else {
|
||||
System.out.println(
|
||||
"\t\tEnglish version exists, no action necessary here.");
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"\tChecking if english variant of the publication item is already associated with the english version of the ZeS item. ");
|
||||
publicationsZeSen.addFilter(String.format("id = %s", publicationEn.
|
||||
getID()));
|
||||
if (publicationsZeSen.isEmpty()) {
|
||||
System.out.println(
|
||||
"\t\tAdding english version of publication item to english version of the ZeS item...");
|
||||
zesEn.addPublication(publicationEn);
|
||||
LifecycleDefinition lifecycleDef =
|
||||
ContentTypeLifecycleDefinition.
|
||||
getLifecycleDefinition(
|
||||
publicationEn.getContentSection(),
|
||||
publicationEn.getContentType());
|
||||
System.out.println("\t\t\t(Re)publishing publication item...");
|
||||
if (publicationEn.isPublished()) {
|
||||
publicationEn.republish();
|
||||
} else {
|
||||
publicationEn.publish(lifecycleDef, new Date());
|
||||
}
|
||||
} else {
|
||||
System.out.println(
|
||||
"\t\tAlready associated, no actions necessary.");
|
||||
}
|
||||
publicationsZeSen.reset();
|
||||
i++;
|
||||
}
|
||||
|
||||
System.out.println("\t\t\t(Re)publishing the english ZeS item...");
|
||||
if (zesEn.isPublished()) {
|
||||
zesEn.republish();
|
||||
} else {
|
||||
LifecycleDefinition lifcycleDef =
|
||||
ContentTypeLifecycleDefinition.
|
||||
getLifecycleDefinition(zesEn.getContentSection(),
|
||||
zesEn.getContentType());
|
||||
zesEn.publish(lifcycleDef, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
public static void fixTheorieUndVerfassung(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection researchContent) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println(
|
||||
"Abteilung Theorie und Verfassung des Wohlfahrtsstaates...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
|
|
@ -94,6 +241,13 @@ public class ZeSLanguageVersionFix {
|
|||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
}
|
||||
|
||||
public static void fixInstitutionenUndGeschichte(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println(
|
||||
"Abteilung Institutionen und Geschichte des Wohlfahrtsstaates...");
|
||||
|
|
@ -114,8 +268,16 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n",
|
||||
institutionenDe.getName(),
|
||||
institutionenDe.getLanguage());
|
||||
}
|
||||
|
||||
public static void fixWirtschaftswissenschaftliche(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println(
|
||||
"Abteilung Wirtschaftswissenschaftliche Abteilung...");
|
||||
|
|
@ -136,8 +298,15 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n", wirtschaftDe.getName(),
|
||||
wirtschaftDe.getLanguage());
|
||||
}
|
||||
|
||||
public static void fixGesundheit(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("Abteilung Gesundheit...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
|
|
@ -159,10 +328,17 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n", gesundheitDe.getName(),
|
||||
gesundheitDe.getLanguage());
|
||||
}
|
||||
|
||||
System.out.println("Arbeitsbereich 1...");
|
||||
public static void fixGesundheitArbeitsbereich1(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("Gesundheit/Arbeitsbereich 1...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
folder = (Folder) folder.getItem(
|
||||
"gesundheit",
|
||||
|
|
@ -180,8 +356,15 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n", arbeitsbereich1De.getName(),
|
||||
arbeitsbereich1De.getLanguage());
|
||||
}
|
||||
|
||||
public static void fixGesundheitArbeitsbereich2(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("Arbeitsbereich 2...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
|
|
@ -201,8 +384,17 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n",
|
||||
arbeitsbereich2De.getName(),
|
||||
arbeitsbereich2De.getLanguage());
|
||||
|
||||
}
|
||||
|
||||
public static void fixGesundheitArbeitsbereich3(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("Arbeitsbereich 3...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
|
|
@ -222,8 +414,16 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n",
|
||||
arbeitsbereich3De.getName(),
|
||||
arbeitsbereich3De.getLanguage());
|
||||
}
|
||||
|
||||
public static void fixGesundheitArbeitsbereich4(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("Arbeitsbereich 4...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
|
|
@ -243,8 +443,17 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n",
|
||||
arbeitsbereich4De.getName(),
|
||||
arbeitsbereich4De.getLanguage());
|
||||
}
|
||||
|
||||
public static void fixGeschlechterpolitik(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("Abteilung Geschlechterpolitik...");
|
||||
folder = sectionContent.getRootFolder();
|
||||
folder = (Folder) folder.getItem("geschlechterpolitik",
|
||||
|
|
@ -262,24 +471,41 @@ public class ZeSLanguageVersionFix {
|
|||
getContentBundle().getPrimaryInstance();
|
||||
}
|
||||
|
||||
System.out.printf("Got '%s' (%s)\n", theorieDe.getName(), theorieDe.
|
||||
getLanguage());
|
||||
System.out.printf("Got '%s' (%s)\n",
|
||||
geschlechterDe.getName(),
|
||||
geschlechterDe.getLanguage());
|
||||
}
|
||||
|
||||
public static void fixFileStorageItems(final Session session,
|
||||
final ContentSection sectionContent,
|
||||
final ContentSection sectionResearch) {
|
||||
Folder folder;
|
||||
ContentItem item;
|
||||
|
||||
System.out.println("FileStorageItems for WorkingPapers...");
|
||||
}
|
||||
|
||||
public static ContentPage createEnglishVersion(final ContentPage item,
|
||||
final ContentSection section) {
|
||||
ContentPage itemPrimary;
|
||||
ContentPage itemEn;
|
||||
|
||||
System.out.println("Finished, commiting transaction...");
|
||||
tctx.commitTxn();
|
||||
} catch (Exception ex) {
|
||||
System.err.println(
|
||||
"Exeception ocurred during convert process. "
|
||||
+ "Transaction rolled back, all changes will be lost.");
|
||||
ex.printStackTrace(System.err);
|
||||
} finally {
|
||||
if (tctx.inTxn()) {
|
||||
tctx.abortTxn();
|
||||
}
|
||||
}
|
||||
itemPrimary = (Publication) item.getContentBundle().
|
||||
getPrimaryInstance();
|
||||
|
||||
itemEn = (Publication) itemPrimary.copy("en");
|
||||
itemEn.setLanguage("en");
|
||||
itemEn.setName(item.getContentBundle().getName());
|
||||
|
||||
ContentType type = item.getContentType();;
|
||||
WorkflowTemplate template = ContentTypeWorkflowTemplate.
|
||||
getWorkflowTemplate(section, type);
|
||||
if (template != null) {
|
||||
Workflow workflow = template.instantiateNewWorkflow();
|
||||
workflow.setObjectID(itemEn.getID());
|
||||
workflow.save();
|
||||
}
|
||||
|
||||
return itemEn;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue