Search in sources :

Example 1 with GroupIdRecordEntity

use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.

the class GroupIdRecordDaoImpl method findByGroupId.

@Override
public GroupIdRecordEntity findByGroupId(String groupId) {
    TypedQuery<GroupIdRecordEntity> query = entityManager.createQuery("from GroupIdRecordEntity where trim(lower(groupId)) = trim(lower(:groupId))", GroupIdRecordEntity.class);
    query.setParameter("groupId", groupId);
    GroupIdRecordEntity result = query.getSingleResult();
    return result;
}
Also used : GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

Example 2 with GroupIdRecordEntity

use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.

the class GroupIdRecordDaoImpl method findByName.

@Override
public GroupIdRecordEntity findByName(String name) {
    TypedQuery<GroupIdRecordEntity> query = entityManager.createQuery("from GroupIdRecordEntity where trim(lower(group_name)) = trim(lower(:group_name))", GroupIdRecordEntity.class);
    query.setParameter("group_name", name);
    GroupIdRecordEntity result = query.getSingleResult();
    return result;
}
Also used : GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

Example 3 with GroupIdRecordEntity

use of org.orcid.persistence.jpa.entities.GroupIdRecordEntity in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_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());
}
Also used : GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord) NoResultException(javax.persistence.NoResultException) OrcidBadRequestException(org.orcid.core.exception.OrcidBadRequestException) AccessControlException(java.security.AccessControlException) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with GroupIdRecordEntity

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);
    addV3CommonFields(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();
}
Also used : GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

Example 5 with GroupIdRecordEntity

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();
    }
}
Also used : OrcidElementCantBeDeletedException(org.orcid.core.exception.OrcidElementCantBeDeletedException) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity) GroupIdRecordNotFoundException(org.orcid.core.exception.GroupIdRecordNotFoundException)

Aggregations

GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)14 GroupIdRecordNotFoundException (org.orcid.core.exception.GroupIdRecordNotFoundException)4 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)4 GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)3 GroupIdRecord (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)3 AccessControlException (java.security.AccessControlException)2 NoResultException (javax.persistence.NoResultException)2 MapperFactory (ma.glasnost.orika.MapperFactory)2 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)2 Test (org.junit.Test)2 OrcidBadRequestException (org.orcid.core.exception.OrcidBadRequestException)2 OrcidElementCantBeDeletedException (org.orcid.core.exception.OrcidElementCantBeDeletedException)2 DBUnitTest (org.orcid.test.DBUnitTest)2 GroupIdRecords (org.orcid.jaxb.model.groupid_v2.GroupIdRecords)1 GroupIdRecords (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords)1