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