use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.
the class GroupIdRecordManagerImpl method createGroupIdRecord.
@Override
public GroupIdRecord createGroupIdRecord(GroupIdRecord groupIdRecord) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
activityValidator.validateGroupIdRecord(groupIdRecord, true, sourceEntity);
validateDuplicate(groupIdRecord);
GroupIdRecordEntity entity = jpaJaxbGroupIdRecordAdapter.toGroupIdRecordEntity(groupIdRecord);
if (sourceEntity != null) {
if (sourceEntity.getSourceClient() != null) {
entity.setClientSourceId(sourceEntity.getSourceClient().getClientId());
} else if (sourceEntity.getSourceProfile() != null) {
entity.setSourceId(sourceEntity.getSourceProfile().getId());
}
}
groupIdRecordDao.persist(entity);
return jpaJaxbGroupIdRecordAdapter.toGroupIdRecord(entity);
}
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 MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreateCanViewAndCreateGroupIds.
@Test
public void testOrcidProfileCreateCanViewAndCreateGroupIds() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
try {
serviceDelegator.viewGroupIdRecord(1L);
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewGroupIdRecords("10", "1");
} catch (Exception e) {
fail();
}
GroupIdRecord groupIdRecord = Utils.getGroupIdRecord();
try {
serviceDelegator.createGroupIdRecord(groupIdRecord);
} catch (Exception e) {
fail();
}
GroupIdRecordEntity toDelete = groupIdRecordDao.findByGroupId(groupIdRecord.getGroupId());
groupIdRecordDao.remove(toDelete.getId());
}
use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getGroupIdRecordMapperFacade.
public MapperFacade getGroupIdRecordMapperFacade() {
MapperFactory mapperFactory = getNewMapperFactory();
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