Cleanup and fixed some potential problems.
parent
55b2f6c6ba
commit
ca87bcb6af
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-18T182914",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-19T185030",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-18T182914",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-19T185030",
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.0.0-beta.127",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-18T182914",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-19T185030",
|
||||
"description": "JavaScript stuff for ccm-cms",
|
||||
"main": "target/generated-resources/assets/@content-sections/cms-admin.js",
|
||||
"types": "target/generated-resources/assets/@content-sections/cms-admin.d.ts",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,13 @@ public abstract class AbstractAssetImExporter<T extends Asset>
|
|||
protected final void updateExistingEntity(
|
||||
final T existingEntity, final T importedEntity
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingEntity.getDisplayName(),
|
||||
importedEntity.getDisplayName()
|
||||
)) {
|
||||
existingEntity.setDisplayName(importedEntity.getDisplayName());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getTitle(),
|
||||
importedEntity.getTitle()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
|
||||
import org.librecms.contentsection.Asset;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -67,7 +66,8 @@ public class Bookmark extends Asset implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "BOOKMARK_DESCRIPTIONS",
|
||||
joinTable = @JoinTable(
|
||||
name = "BOOKMARK_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
|
|
|
|||
|
|
@ -96,12 +96,10 @@ public class ContactableEntity extends Asset {
|
|||
}
|
||||
|
||||
protected void addContactEntry(final ContactEntry contactEntry) {
|
||||
|
||||
contactEntries.add(contactEntry);
|
||||
}
|
||||
|
||||
protected void removeContactEntry(final ContactEntry contactEntry) {
|
||||
|
||||
contactEntries.remove(contactEntry);
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +125,6 @@ public class ContactableEntity extends Asset {
|
|||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -158,13 +155,15 @@ public class ContactableEntity extends Asset {
|
|||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
|
||||
return super.toString(String.format(
|
||||
return super.toString(
|
||||
String.format(
|
||||
"contactEntries = { %s }, "
|
||||
+ "postalAddress = %s%s",
|
||||
Objects.toString(contactEntries),
|
||||
Objects.toString(postalAddress),
|
||||
data));
|
||||
data
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,31 +87,6 @@ public class Person extends ContactableEntity {
|
|||
)
|
||||
private List<PersonName> personNames;
|
||||
|
||||
// /**
|
||||
// * The surname/familyname of the person
|
||||
// */
|
||||
// @Column(name = "SURNAME")
|
||||
// private String surname;
|
||||
//
|
||||
// /**
|
||||
// * The given name of the person.
|
||||
// */
|
||||
// @Column(name = "GIVEN_NAME")
|
||||
// private String givenName;
|
||||
//
|
||||
// /**
|
||||
// * Any prefixes to the name of the person. Examples are Prof. or Dr.
|
||||
// */
|
||||
// @Column(name = "NAME_PREFIX")
|
||||
// private String prefix;
|
||||
//
|
||||
// /**
|
||||
// * Any suffixes to the name of the person. Examples for suffixes are
|
||||
// * PhD, or especially for Great Britain the membership in various orders,
|
||||
// * for example KBE or CBE.
|
||||
// */
|
||||
// @Column(name = "SUFFIX")
|
||||
// private String suffix;
|
||||
/**
|
||||
* The birthdate of the person.
|
||||
*/
|
||||
|
|
@ -125,37 +100,6 @@ public class Person extends ContactableEntity {
|
|||
personNames = new ArrayList<>();
|
||||
}
|
||||
|
||||
// public String getSurname() {
|
||||
// return surname;
|
||||
// }
|
||||
//
|
||||
// public void setSurname(final String surname) {
|
||||
// this.surname = surname;
|
||||
// }
|
||||
//
|
||||
// public String getGivenName() {
|
||||
// return givenName;
|
||||
// }
|
||||
//
|
||||
// public void setGivenName(final String givenName) {
|
||||
// this.givenName = givenName;
|
||||
// }
|
||||
//
|
||||
// public String getPrefix() {
|
||||
// return prefix;
|
||||
// }
|
||||
//
|
||||
// public void setPrefix(final String prefix) {
|
||||
// this.prefix = prefix;
|
||||
// }
|
||||
//
|
||||
// public String getSuffix() {
|
||||
// return suffix;
|
||||
// }
|
||||
//
|
||||
// public void setSuffix(final String suffix) {
|
||||
// this.suffix = suffix;
|
||||
// }
|
||||
public List<PersonName> getPersonNames() {
|
||||
|
||||
return Collections.unmodifiableList(personNames);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
|
||||
import org.librecms.contentsection.Asset;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
|
@ -64,7 +63,8 @@ public class SideNote extends Asset implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "SIDE_NOTE_TEXTS",
|
||||
joinTable = @JoinTable(
|
||||
name = "SIDE_NOTE_TEXTS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "SIDE_NOTE_ID")
|
||||
|
|
|
|||
|
|
@ -51,6 +51,14 @@ public class VideoAssetImExporter
|
|||
final VideoAsset existingAsset,
|
||||
final VideoAsset importedAsset
|
||||
) {
|
||||
if (existingAsset.getWidth() != importedAsset.getWidth()) {
|
||||
existingAsset.setWidth(importedAsset.getWidth());
|
||||
}
|
||||
|
||||
if (existingAsset.getHeight() != importedAsset.getHeight()) {
|
||||
existingAsset.setHeight(importedAsset.getHeight());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingAsset.getLegalMetadata(),
|
||||
importedAsset.getLegalMetadata()
|
||||
|
|
|
|||
|
|
@ -122,13 +122,6 @@ public abstract class AbstractContentItemImExporter<T extends ContentItem>
|
|||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getContentType(),
|
||||
importedEntity.getContentType()
|
||||
)) {
|
||||
existingEntity.setContentType(importedEntity.getContentType());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getTitle(),
|
||||
importedEntity.getTitle()
|
||||
|
|
|
|||
|
|
@ -650,7 +650,8 @@ public class ContentItem extends CcmObject implements Serializable, Exportable {
|
|||
name = "CONTENT_ITEM_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
))
|
||||
@IndexedEmbedded
|
||||
@XmlElement(name = "description", namespace = CMS_XML_NS)
|
||||
|
|
|
|||
|
|
@ -78,13 +78,6 @@ public class ContentTypeImExporter
|
|||
existingEntity.setDisplayName(importedEntity.getDisplayName());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getContentSection(),
|
||||
importedEntity.getContentSection()
|
||||
)) {
|
||||
existingEntity.setContentSection(importedEntity.getContentSection());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getLabel(),
|
||||
importedEntity.getLabel()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package org.librecms.contentsection;
|
||||
|
||||
import net.bytebuddy.build.Plugin;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryManager;
|
||||
import org.libreccm.categorization.Domain;
|
||||
|
|
@ -14,7 +13,6 @@ import java.util.Set;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 LibreCCM Foundation.
|
||||
|
|
@ -122,28 +120,6 @@ public class FolderImExporter extends AbstractEntityImExporter<Folder> {
|
|||
existingEntity.setName(withImportedEntity.getName());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getParentCategory(),
|
||||
withImportedEntity.getParentCategory()
|
||||
)) {
|
||||
categoryManager.removeSubCategoryFromCategory(
|
||||
existingEntity,
|
||||
existingEntity.getParentCategory()
|
||||
);
|
||||
|
||||
categoryManager.addSubCategoryToCategory(
|
||||
withImportedEntity.getParentCategory(),
|
||||
existingEntity
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getSection(),
|
||||
withImportedEntity.getSection()
|
||||
)) {
|
||||
existingEntity.setSection(withImportedEntity.getSection());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getTitle(),
|
||||
withImportedEntity.getTitle()
|
||||
|
|
|
|||
|
|
@ -67,11 +67,14 @@ public class Article extends ContentItem implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "ARTICLE_TEXTS",
|
||||
joinTable = @JoinTable(
|
||||
name = "ARTICLE_TEXTS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString text;
|
||||
|
||||
public Article() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.librecms.contenttypes;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
|
@ -71,11 +70,14 @@ public class Event extends ContentItem implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "EVENT_TEXTS",
|
||||
joinTable = @JoinTable(
|
||||
name = "EVENT_TEXTS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString text;
|
||||
|
||||
@Column(name = "START_DATE")
|
||||
|
|
@ -92,11 +94,14 @@ public class Event extends ContentItem implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "EVENT_DATES",
|
||||
joinTable = @JoinTable(
|
||||
name = "EVENT_DATES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString eventDate;
|
||||
|
||||
/**
|
||||
|
|
@ -105,11 +110,14 @@ public class Event extends ContentItem implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "EVENT_LOCATIONS",
|
||||
joinTable = @JoinTable(
|
||||
name = "EVENT_LOCATIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString location;
|
||||
|
||||
/**
|
||||
|
|
@ -118,21 +126,27 @@ public class Event extends ContentItem implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "EVENT_MAIN_CONTRIBUTORS",
|
||||
joinTable = @JoinTable(
|
||||
name = "EVENT_MAIN_CONTRIBUTORS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString mainContributor;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "EVENT_TYPES",
|
||||
joinTable = @JoinTable(
|
||||
name = "EVENT_TYPES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString eventType;
|
||||
|
||||
//ToDo: check if this is necessary or can be better handled using related links.
|
||||
|
|
@ -145,11 +159,14 @@ public class Event extends ContentItem implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "EVENT_COSTS",
|
||||
joinTable = @JoinTable(
|
||||
name = "EVENT_COSTS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString cost;
|
||||
|
||||
public Event() {
|
||||
|
|
|
|||
|
|
@ -82,16 +82,19 @@ public class MultiPartArticleImExporter
|
|||
);
|
||||
}
|
||||
|
||||
final List<MultiPartArticleSection> missingSections = importedContentItem
|
||||
final List<MultiPartArticleSection> missingSections
|
||||
= importedContentItem
|
||||
.getSections()
|
||||
.stream()
|
||||
.filter(
|
||||
section -> existingContentItem.getSections().contains(section)
|
||||
section -> existingContentItem.getSections().contains(
|
||||
section)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (final MultiPartArticleSection missingSection : missingSections) {
|
||||
final MultiPartArticleSection newSection = new MultiPartArticleSection();
|
||||
final MultiPartArticleSection newSection
|
||||
= new MultiPartArticleSection();
|
||||
newSection.setPageBreak(missingSection.isPageBreak());
|
||||
newSection.setRank(missingSection.getRank());
|
||||
syncLocalizedStrings(
|
||||
|
|
|
|||
|
|
@ -102,13 +102,6 @@ public class LifecycleDefinitionImExporter
|
|||
);
|
||||
}
|
||||
|
||||
for (final PhaseDefinition phaseDef : importedEntity
|
||||
.getPhaseDefinitions()) {
|
||||
if (!existingEntity.getPhaseDefinitions().contains(phaseDef)) {
|
||||
existingEntity.addPhaseDefinition(phaseDef);
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleDefRepo.save(existingEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ public class PhaseDefinition implements Exportable, Serializable {
|
|||
this.definitionId = definitionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,15 @@ public class PhaseDefinitionImExporter
|
|||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getDefaultListener(),
|
||||
importedEntity.getDefaultListener()
|
||||
)) {
|
||||
existingEntity.setDefaultListener(
|
||||
importedEntity.getDefaultListener()
|
||||
);
|
||||
}
|
||||
|
||||
phaseDefinitionRepo.save(existingEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,20 +95,6 @@ public class PhaseImExporter
|
|||
existingEntity.setFinished(importedEntity.isFinished());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getLifecycle(),
|
||||
importedEntity.getLifecycle()
|
||||
)) {
|
||||
existingEntity.setLifecycle(importedEntity.getLifecycle());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getDefinition(),
|
||||
importedEntity.getDefinition()
|
||||
)) {
|
||||
existingEntity.setDefinition(importedEntity.getDefinition());
|
||||
}
|
||||
|
||||
phaseRepo.save(existingEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,21 +76,6 @@ public class CategorizationImExporter
|
|||
protected void updateExistingEntity(
|
||||
final Categorization existingEntity, final Categorization importedEntity
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingEntity.getCategory(), importedEntity.getCategory()
|
||||
)) {
|
||||
existingEntity.setCategory(importedEntity.getCategory());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getCategorizedObject(),
|
||||
importedEntity.getCategorizedObject()
|
||||
)) {
|
||||
existingEntity.setCategorizedObject(
|
||||
importedEntity.getCategorizedObject()
|
||||
);
|
||||
}
|
||||
|
||||
if (existingEntity.isIndexObject() != importedEntity.isIndexObject()) {
|
||||
existingEntity.setIndexObject(importedEntity.isIndexObject());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,45 +115,6 @@ public class CategoryImExporter extends AbstractEntityImExporter<Category> {
|
|||
existingEntity.setName(importedEntity.getName());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getParentCategory(),
|
||||
importedEntity.getParentCategory()
|
||||
)) {
|
||||
final Category oldParentCategory = existingEntity
|
||||
.getParentCategory();
|
||||
final Category newParentCategory = importedEntity
|
||||
.getParentCategory();
|
||||
|
||||
categoryManager.removeSubCategoryFromCategory(
|
||||
existingEntity,
|
||||
oldParentCategory
|
||||
);
|
||||
|
||||
categoryManager.addSubCategoryToCategory(
|
||||
existingEntity,
|
||||
newParentCategory
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getSubCategories(),
|
||||
importedEntity.getSubCategories()
|
||||
)) {
|
||||
final Set<Category> subCategoriesToAdd = importedEntity
|
||||
.getSubCategories()
|
||||
.stream()
|
||||
.filter(
|
||||
category -> !existingEntity.getSubCategories().contains(
|
||||
category
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for(final Category category : subCategoriesToAdd) {
|
||||
existingEntity.addSubCategory(category);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getTitle(),
|
||||
importedEntity.getTitle()
|
||||
|
|
|
|||
|
|
@ -71,6 +71,13 @@ public class DomainImExporter extends AbstractEntityImExporter<Domain> {
|
|||
final Domain existingEntity,
|
||||
final Domain importedEntity
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingEntity.getDisplayName(),
|
||||
importedEntity.getDisplayName()
|
||||
)) {
|
||||
importedEntity.setDisplayName(importedEntity.getDisplayName());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getDomainKey(),
|
||||
importedEntity.getDomainKey()
|
||||
|
|
@ -116,24 +123,6 @@ public class DomainImExporter extends AbstractEntityImExporter<Domain> {
|
|||
existingEntity.setReleased(importedEntity.getReleased());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getOwners(),
|
||||
importedEntity.getOwners()
|
||||
)) {
|
||||
final Set<DomainOwnership> ownersToAdd = importedEntity
|
||||
.getOwners()
|
||||
.stream()
|
||||
.filter(owner -> !existingEntity.getOwners().contains(owner))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (final DomainOwnership toAdd : ownersToAdd) {
|
||||
domainManager.addDomainOwner(toAdd.getOwner(),
|
||||
existingEntity,
|
||||
toAdd.getContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
domainRepository.save(existingEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ public class DomainOwnershipImExporter
|
|||
domainOwnershipRepo.save(entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected DomainOwnership reloadEntity(final DomainOwnership entity) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -83,47 +83,7 @@ public class GroupMembershipImExporter
|
|||
final GroupMembership existingEntity,
|
||||
final GroupMembership importedEntity
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingEntity.getGroup(),
|
||||
importedEntity.getGroup()
|
||||
) && !Objects.equals(
|
||||
existingEntity.getMember(),
|
||||
importedEntity.getMember()
|
||||
)) {
|
||||
final Group oldGroup = existingEntity.getGroup();
|
||||
final User oldMember = existingEntity.getMember();
|
||||
final Group newGroup = importedEntity.getGroup();
|
||||
final User newMember = importedEntity.getMember();
|
||||
|
||||
groupManager.removeMemberFromGroup(oldMember, oldGroup);
|
||||
groupManager.addMemberToGroup(newMember, newGroup);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getGroup(),
|
||||
importedEntity.getGroup()
|
||||
)) {
|
||||
final Group oldGroup = existingEntity.getGroup();
|
||||
final Group newGroup = importedEntity.getGroup();
|
||||
final User member = existingEntity.getMember();
|
||||
|
||||
groupManager.removeMemberFromGroup(member, oldGroup);
|
||||
groupManager.addMemberToGroup(member, newGroup);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getMember(),
|
||||
importedEntity.getMember()
|
||||
)) {
|
||||
final User oldMember = existingEntity.getMember();
|
||||
final User newMember = importedEntity.getMember();
|
||||
final Group group = existingEntity.getGroup();
|
||||
|
||||
groupManager.removeMemberFromGroup(oldMember, group);
|
||||
groupManager.addMemberToGroup(newMember, group);
|
||||
}
|
||||
|
||||
groupMembershipRepo.save(existingEntity);
|
||||
// Nothing to update in a GroupMembership
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -105,13 +105,6 @@ public class PermissionImExporter extends AbstractEntityImExporter<Permission> {
|
|||
existingEntity.setInherited(importedEntity.isInherited());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getInheritedFrom(),
|
||||
importedEntity.getInheritedFrom()
|
||||
)) {
|
||||
existingEntity.setInheritedFrom(importedEntity.getInheritedFrom());
|
||||
}
|
||||
|
||||
permissionRepository.save(existingEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,20 +82,7 @@ public class RoleMembershipImExporter
|
|||
final RoleMembership existingEntity,
|
||||
final RoleMembership importedEntity
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingEntity.getRole(),
|
||||
importedEntity.getRole()
|
||||
)) {
|
||||
existingEntity.setRole(importedEntity.getRole());
|
||||
}
|
||||
if (!Objects.equals(
|
||||
existingEntity.getMember(),
|
||||
importedEntity.getMember()
|
||||
)) {
|
||||
existingEntity.setMember(importedEntity.getMember());
|
||||
}
|
||||
|
||||
membershipRepo.save(existingEntity);
|
||||
// Nothing to update in a RoleMembership
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -105,17 +105,48 @@ public class AssignableTaskImExporter
|
|||
existingEntity.setActive(importedEntity.isActive());
|
||||
}
|
||||
|
||||
if (existingEntity.getTaskState() != importedEntity.getTaskState()) {
|
||||
existingEntity.setTaskState(importedEntity.getTaskState());
|
||||
}
|
||||
|
||||
if (existingEntity.isLocked() != importedEntity.isLocked()) {
|
||||
existingEntity.setLocked(importedEntity.isLocked());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getWorkflow(),
|
||||
importedEntity.getWorkflow()
|
||||
existingEntity.getLockingUser(),
|
||||
importedEntity.getLockingUser()
|
||||
)) {
|
||||
taskManager.removeTask(
|
||||
existingEntity.getWorkflow(),
|
||||
existingEntity
|
||||
existingEntity.setLockingUser(importedEntity.getLockingUser());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getStartDate(),
|
||||
importedEntity.getStartDate()
|
||||
)) {
|
||||
existingEntity.setStartDate(importedEntity.getStartDate());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getDueDate(),
|
||||
importedEntity.getDueDate()
|
||||
)) {
|
||||
existingEntity.setDueDate(importedEntity.getDueDate());
|
||||
}
|
||||
|
||||
if (existingEntity.getDurationMinutes() != importedEntity
|
||||
.getDurationMinutes()) {
|
||||
existingEntity.setDurationMinutes(
|
||||
importedEntity.getDurationMinutes()
|
||||
);
|
||||
taskManager.addTask(
|
||||
importedEntity.getWorkflow(),
|
||||
existingEntity
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getNotificationSender(),
|
||||
importedEntity.getNotificationSender()
|
||||
)) {
|
||||
existingEntity.setNotificationSender(
|
||||
importedEntity.getNotificationSender()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import javax.enterprise.context.RequestScoped;
|
|||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Exporter/Importer for {@link TaskDependency} entities.
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ import org.libreccm.imexport.Processes;
|
|||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
|
@ -78,13 +76,6 @@ public class WorkflowImExporter extends AbstractEntityImExporter<Workflow> {
|
|||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getTemplate(),
|
||||
importedEntity.getTemplate()
|
||||
)) {
|
||||
existingEntity.setTemplate(importedEntity.getTemplate());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getName(),
|
||||
importedEntity.getName()
|
||||
|
|
@ -117,30 +108,7 @@ public class WorkflowImExporter extends AbstractEntityImExporter<Workflow> {
|
|||
existingEntity.setTasksState(importedEntity.getTasksState());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getObject(),
|
||||
importedEntity.getObject()
|
||||
)) {
|
||||
existingEntity.setObject(importedEntity.getObject());
|
||||
}
|
||||
|
||||
workflowRepository.save(importedEntity);
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getTasks(),
|
||||
importedEntity.getTasks()
|
||||
)) {
|
||||
|
||||
final Set<Task> tasksToAdd = importedEntity
|
||||
.getTasks()
|
||||
.stream()
|
||||
.filter(task -> !existingEntity.getTasks().contains(task))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (final Task task : tasksToAdd) {
|
||||
taskManager.addTask(existingEntity, task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import javax.annotation.PostConstruct;
|
|||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Im/Exporter for importing and exporting {@code File}s from the system into a
|
||||
|
|
@ -150,20 +149,6 @@ public class FileImExporter extends AbstractEntityImExporter<File> {
|
|||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getParent(),
|
||||
importedEntity.getParent()
|
||||
)) {
|
||||
existingEntity.setParent(importedEntity.getParent());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getRepository(),
|
||||
importedEntity.getRepository()
|
||||
)) {
|
||||
existingEntity.setRepository(importedEntity.getRepository());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getContent(),
|
||||
importedEntity.getContent()
|
||||
|
|
|
|||
|
|
@ -147,29 +147,6 @@ public class FolderImExporter extends AbstractResourceImExporter<Folder> {
|
|||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getParent(),
|
||||
importedEntity.getParent()
|
||||
)) {
|
||||
existingEntity.setParent(importedEntity.getParent());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getRepository(),
|
||||
importedEntity.getRepository()
|
||||
)) {
|
||||
existingEntity.setRepository(importedEntity.getRepository());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getRootAssignedRepository(),
|
||||
importedEntity.getRootAssignedRepository()
|
||||
)) {
|
||||
existingEntity.setRootAssignedRepository(
|
||||
importedEntity.getRootAssignedRepository()
|
||||
);
|
||||
}
|
||||
|
||||
folderRepository.save(importedEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,13 +117,6 @@ public class RepositoryImExporter extends AbstractEntityImExporter<Repository> {
|
|||
existingEntity.setName(importedEntity.getName());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getRootFolder(),
|
||||
importedEntity.getRootFolder()
|
||||
)) {
|
||||
existingEntity.setRootFolder(importedEntity.getRootFolder());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getOwner(),
|
||||
importedEntity.getOwner()
|
||||
|
|
|
|||
Loading…
Reference in New Issue