Several bugfixes
parent
71a033cfd1
commit
c3ab47ad90
|
|
@ -46,7 +46,9 @@ public class JournalRepository extends AbstractEntityRepository<Long, Journal> {
|
|||
|
||||
@Override
|
||||
protected void initNewEntity(final Journal entity) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -53,8 +53,9 @@ public class PublicationRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Publication entity) {
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
entity.setUuid(uuid);
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@ public class PublicationWithPublisherRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final PublicationWithPublisher entity) {
|
||||
publicationRepository.initNewEntity(entity);
|
||||
if (entity.getUuid() == null) {
|
||||
publicationRepository.initNewEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ public class PublisherRepository
|
|||
|
||||
@Override
|
||||
protected void initNewEntity(final Publisher entity) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
@ -63,7 +65,7 @@ public class PublisherRepository
|
|||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<Publisher> findByName(final String name) {
|
||||
return getEntityManager()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ public class SeriesRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Series entity) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ public class ContactRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Contact contact) {
|
||||
contact.setUuid(UUID.randomUUID().toString());
|
||||
if (contact.getUuid() == null) {
|
||||
contact.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ public class DepartmentProjectRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final DepartmentProject project) {
|
||||
project.setUuid(UUID.randomUUID().toString());
|
||||
if (project.getUuid() == null) {
|
||||
project.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ public class MembershipRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Membership membership) {
|
||||
membership.setUuid(UUID.randomUUID().toString());
|
||||
if (membership.getUuid() == null) {
|
||||
membership.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -43,24 +43,27 @@ public class ContactRepository
|
|||
public boolean isNew(final Contact contact) {
|
||||
return contact.getContactId() == 0 || contact.getUuid() == null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initNewEntity(final Contact contact) {
|
||||
contact.setUuid(UUID.randomUUID().toString());
|
||||
if (contact.getUuid() == null) {
|
||||
contact.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Optional<Contact> findByUuid(final String uuid) {
|
||||
try {
|
||||
return Optional.of(
|
||||
getEntityManager()
|
||||
.createNamedQuery("SciProjectContact.findByUuid", Contact.class)
|
||||
.setParameter("uuid", uuid)
|
||||
.getSingleResult()
|
||||
);
|
||||
} catch(NoResultException ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
try {
|
||||
return Optional.of(
|
||||
getEntityManager()
|
||||
.createNamedQuery("SciProjectContact.findByUuid",
|
||||
Contact.class)
|
||||
.setParameter("uuid", uuid)
|
||||
.getSingleResult()
|
||||
);
|
||||
} catch (NoResultException ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue