Some bugfixes for imports
parent
51d77b998a
commit
8f369ba21a
|
|
@ -1,5 +1,7 @@
|
||||||
package org.scientificcms.contenttypes.scidepartment;
|
package org.scientificcms.contenttypes.scidepartment;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||||
import org.libreccm.imexport.Processes;
|
import org.libreccm.imexport.Processes;
|
||||||
import org.librecms.assets.Organization;
|
import org.librecms.assets.Organization;
|
||||||
|
|
@ -22,6 +24,10 @@ import javax.transaction.Transactional;
|
||||||
@Processes(Contact.class)
|
@Processes(Contact.class)
|
||||||
public class ContactImExporter
|
public class ContactImExporter
|
||||||
extends AbstractEntityImExporter<Contact> {
|
extends AbstractEntityImExporter<Contact> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(
|
||||||
|
ContactImExporter.class
|
||||||
|
);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ContactRepository contactRepo;
|
private ContactRepository contactRepo;
|
||||||
|
|
@ -46,6 +52,11 @@ public class ContactImExporter
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected void saveImportedEntity(final Contact entity) {
|
protected void saveImportedEntity(final Contact entity) {
|
||||||
|
LOGGER.info(
|
||||||
|
"Saving {}: {}",
|
||||||
|
entity.getClass().getName(),
|
||||||
|
Objects.toString(entity)
|
||||||
|
);
|
||||||
contactRepo.save(entity);
|
contactRepo.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ public class Contact implements Exportable, Serializable {
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long contactId;
|
private long contactId;
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "uuid", unique = true, nullable = false)
|
@Column(name = "uuid", unique = true, nullable = false)
|
||||||
private String uuid;
|
private String uuid;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package org.scientificcms.contenttypes.sciproject;
|
package org.scientificcms.contenttypes.sciproject;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||||
import org.libreccm.imexport.Processes;
|
import org.libreccm.imexport.Processes;
|
||||||
import org.librecms.assets.Organization;
|
import org.librecms.assets.Organization;
|
||||||
|
|
@ -23,6 +25,10 @@ import javax.transaction.Transactional;
|
||||||
@Processes(Contact.class)
|
@Processes(Contact.class)
|
||||||
public class ContactImExporter
|
public class ContactImExporter
|
||||||
extends AbstractEntityImExporter<Contact> {
|
extends AbstractEntityImExporter<Contact> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(
|
||||||
|
ContactImExporter.class
|
||||||
|
);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ContactRepository contactRepo;
|
private ContactRepository contactRepo;
|
||||||
|
|
@ -50,10 +56,7 @@ public class ContactImExporter
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected void saveImportedEntity(final Contact entity) {
|
protected void saveImportedEntity(final Contact entity) {
|
||||||
final SciProject project = entity.getProject();
|
|
||||||
project.addContact(entity);
|
|
||||||
contactRepo.save(entity);
|
contactRepo.save(entity);
|
||||||
itemRepo.save(project);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,7 @@ public class MembershipImExporter
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected void saveImportedEntity(final Membership entity) {
|
protected void saveImportedEntity(final Membership entity) {
|
||||||
final SciProject project = entity.getProject();
|
|
||||||
project.addMember(entity);
|
|
||||||
membershipRepo.save(entity);
|
membershipRepo.save(entity);
|
||||||
itemRepo.save(project);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class SciProjectIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
return CdiUtil
|
final SciProject project = CdiUtil
|
||||||
.createCdiUtil()
|
.createCdiUtil()
|
||||||
.findBean(ContentItemRepository.class)
|
.findBean(ContentItemRepository.class)
|
||||||
.findByUuid(id.key.toString(), SciProject.class)
|
.findByUuid(id.key.toString(), SciProject.class)
|
||||||
|
|
@ -42,6 +42,18 @@ public class SciProjectIdResolver implements Serializable, ObjectIdResolver {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ContentItemRepository.class)
|
||||||
|
.findByUuid(id.key.toString(), SciProject.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No SciProject with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue