Commit e91c3e1d authored by michael.simon's avatar michael.simon
Browse files

add find all registries from external users for service

parent 23e502a7
......@@ -82,4 +82,6 @@ public interface RegistryDao extends BaseDao<RegistryEntity, Long> {
RegistryEntity findByServiceAndIdentityAndStatus(ServiceEntity service, IdentityEntity identity,
RegistryStatus status);
List<RegistryEntity> findAllExternalBySsn(String serviceShortName);
}
......@@ -28,6 +28,7 @@ import javax.persistence.criteria.Root;
import edu.kit.scc.webreg.dao.GenericSortOrder;
import edu.kit.scc.webreg.dao.RegistryDao;
import edu.kit.scc.webreg.entity.ExternalUserEntity;
import edu.kit.scc.webreg.entity.RegistryEntity;
import edu.kit.scc.webreg.entity.RegistryEntity_;
import edu.kit.scc.webreg.entity.RegistryStatus;
......@@ -132,6 +133,16 @@ public class JpaRegistryDao extends JpaBaseDao<RegistryEntity, Long> implements
.setMaxResults(limit).getResultList();
}
@SuppressWarnings("unchecked")
@Override
public List<RegistryEntity> findAllExternalBySsn(String serviceShortName) {
return em.createQuery("select r from RegistryEntity r where r.service.shortName = :ssn and "
+ " TYPE(r.user) = :class")
.setParameter("ssn", serviceShortName)
.setParameter("class", ExternalUserEntity.class)
.getResultList();
}
@SuppressWarnings("unchecked")
@Override
public List<RegistryEntity> findByServiceAndStatusAndIDPGood(String serviceShortName, RegistryStatus status, Date date, int limit) {
......
......@@ -21,4 +21,5 @@ public interface RegistryDtoService extends BaseDtoService<RegistryEntity, Regis
List<RegistryEntityDto> findRegistriesByStatus(ServiceEntity service, RegistryStatus status);
List<RegistryEntityDto> findAllExternalBySsn(String ssn);
}
......@@ -77,7 +77,19 @@ public class RegistryDtoServiceImpl extends BaseDtoServiceImpl<RegistryEntity, R
}
return dtoList;
}
@Override
public List<RegistryEntityDto> findAllExternalBySsn(String ssn) {
List<RegistryEntity> regList = dao.findAllExternalBySsn(ssn);
List<RegistryEntityDto> dtoList = new ArrayList<RegistryEntityDto>(regList.size());
for (RegistryEntity reg : regList) {
RegistryEntityDto dto = createNewDto();
mapper.copyProperties(reg, dto);
dtoList.add(dto);
}
return dtoList;
}
@Override
public RegistryEntityDto register(String externalId, String ssn)
throws RegisterException {
......
......@@ -74,5 +74,13 @@ public class ExternalRegistryController {
return registryDtoService.findByExternalId(externalId);
}
@Path(value = "/find/all/ssn/{ssn}")
@Produces({MediaType.APPLICATION_JSON})
@GET
public List<RegistryEntityDto> findAll(@PathParam("ssn") String ssn, @Context HttpServletRequest request)
throws IOException, RestInterfaceException, ServletException {
return registryDtoService.findAllExternalBySsn(ssn);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment