use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.
the class GroupIdRecordManagerImpl method deleteGroupIdRecord.
@Override
public void deleteGroupIdRecord(Long putCode) {
GroupIdRecordEntity existingEntity = groupIdRecordDao.find(putCode);
if (existingEntity != null) {
if (groupIdRecordDao.haveAnyPeerReview(existingEntity.getGroupId())) {
throw new OrcidElementCantBeDeletedException("Unable to delete group id because there are peer reviews associated to it");
}
orcidSecurityManager.checkSource(existingEntity);
groupIdRecordDao.remove(Long.valueOf(putCode));
} else {
throw new GroupIdRecordNotFoundException();
}
}
use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.
the class GroupIdRecordManagerImpl method updateGroupIdRecord.
@Override
public GroupIdRecord updateGroupIdRecord(Long putCode, GroupIdRecord groupIdRecord) {
GroupIdRecordEntity existingEntity = groupIdRecordDao.find(putCode);
if (existingEntity == null) {
throw new GroupIdRecordNotFoundException();
}
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
// Save the original source
String existingSourceId = existingEntity.getSourceId();
String existingClientSourceId = existingEntity.getClientSourceId();
activityValidator.validateGroupIdRecord(groupIdRecord, false, sourceEntity);
validateDuplicate(groupIdRecord);
orcidSecurityManager.checkSource(existingEntity);
GroupIdRecordEntity updatedEntity = jpaJaxbGroupIdRecordAdapter.toGroupIdRecordEntity(groupIdRecord);
updatedEntity.setDateCreated(existingEntity.getDateCreated());
// Be sure it doesn't overwrite the source
updatedEntity.setSourceId(existingSourceId);
updatedEntity.setClientSourceId(existingClientSourceId);
updatedEntity = groupIdRecordDao.merge(updatedEntity);
return jpaJaxbGroupIdRecordAdapter.toGroupIdRecord(updatedEntity);
}
use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getGroupIdRecordMapperFacade.
public MapperFacade getGroupIdRecordMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<GroupIdRecord, GroupIdRecordEntity> classMap = mapperFactory.classMap(GroupIdRecord.class, GroupIdRecordEntity.class);
addV2CommonFields(classMap);
registerSourceConverters(mapperFactory, classMap);
classMap.field("name", "groupName");
classMap.field("groupId", "groupId");
classMap.field("description", "groupDescription");
classMap.field("type", "groupType");
classMap.register();
return mapperFactory.getMapperFacade();
}
Aggregations