Skip to content
Snippets Groups Projects
Commit 5d334089 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Adds collection of forecasts for an organization

parent ac9ca3cc
No related branches found
No related tags found
No related merge requests found
......@@ -37,8 +37,8 @@ public class VIPSCoreManagerApplication extends Application
* given list with all resources defined in the project.
*/
private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(no.bioforsk.vips.core.service.ModelResource.class);
resources.add(no.bioforsk.vips.coremanager.service.JsonParseExceptionMapper.class);
resources.add(no.bioforsk.vips.coremanager.service.ManagerResource.class);
resources.add(no.bioforsk.vips.coremanager.service.ManagerResourceImpl.class);
}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@NamedQueries({
@NamedQuery(name = "VipsCoreUser.findAll", query = "SELECT v FROM VipsCoreUser v"),
@NamedQuery(name = "VipsCoreUser.findByVipsCoreUserId", query = "SELECT v FROM VipsCoreUser v WHERE v.vipsCoreUserId = :vipsCoreUserId"),
@NamedQuery(name = "VipsCoreUser.findByOrganizationId", query = "SELECT v FROM VipsCoreUser v WHERE v.organizationId = :organizationId"),
@NamedQuery(name = "VipsCoreUser.findByFirstName", query = "SELECT v FROM VipsCoreUser v WHERE v.firstName = :firstName"),
@NamedQuery(name = "VipsCoreUser.findByLastName", query = "SELECT v FROM VipsCoreUser v WHERE v.lastName = :lastName")})
public class VipsCoreUser implements Serializable {
......
......@@ -6,6 +6,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -116,7 +117,19 @@ public class ManagerResourceImpl implements ManagerResource{
}
@GET
@Path("models/{modelId}/name")
@Produces("text/plain;charset=UTF-8")
public Response printModelName(@PathParam("modelId") String modelId) {
return this.printModelName(modelId, Model.DEFAULT_LANGUAGE);
}
@GET
@Path("models/{modelId}/name/{language}")
@Produces("text/plain;charset=UTF-8")
public Response printModelName(@PathParam("modelId") String modelId, @PathParam("language") String language) {
return Response.ok().entity(this.getModelResource().printModelName(modelId, language).readEntity(String.class)).build();
}
@GET
......@@ -211,6 +224,22 @@ public class ManagerResourceImpl implements ManagerResource{
}
}
/**
* Fetches users that belong to given organization
* TODO: Should be authenticated (how to structure this???)
* @param organizationId
* @return
*/
@GET
@Path("organizations/{organizationId}/users")
@Produces("application/json")
@Override
public Response getUsersForOrganization(@PathParam("organizationId") Integer organizationId)
{
List<VipsCoreUser> users = ControllerGetter.getUserController().getVipsCoreUserForOrganization(organizationId);
return Response.ok().entity(users).build();
}
/**
* Instantiates and runs the requested model
* @param modelId
......
......@@ -2,6 +2,7 @@ package no.bioforsk.vips.coremanager.session;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.ejb.LocalBean;
......@@ -11,6 +12,7 @@ import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import no.bioforsk.vips.coremanager.entity.ModelUsageLog;
import no.bioforsk.vips.coremanager.entity.Organization;
import no.bioforsk.vips.coremanager.entity.VIPSCoreCredentials;
import no.bioforsk.vips.coremanager.entity.VipsCoreUser;
import no.bioforsk.vips.util.MD5Encrypter;
......@@ -61,6 +63,14 @@ public class UserController {
return em.find(VipsCoreUser.class, userId);
}
public List<VipsCoreUser> getVipsCoreUserForOrganization(Integer organizationId)
{
Organization organization = em.find(Organization.class, organizationId);
Query q = em.createNamedQuery("VipsCoreUser.findByOrganizationId");
q.setParameter("organizationId", organization);
return q.getResultList();
}
/**
* @return Properties for this server
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment