implemented get

pull/708/merge
Justin Richer 2015-02-24 15:09:52 -05:00
parent 3076da1ed8
commit 0b480bac10
7 changed files with 32 additions and 2 deletions

View File

@ -28,7 +28,6 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@ -113,9 +112,10 @@ public class ResourceSet {
* @return the scopes
*/
@ElementCollection(fetch=FetchType.EAGER)
@Column(name = "scope")
@CollectionTable(
name="resource_set_scope",
joinColumns=@JoinColumn(name="owner_id")
joinColumns=@JoinColumn(name = "owner_id")
)
public Set<String> getScopes() {
return scopes;

View File

@ -29,4 +29,6 @@ public interface ResourceSetService {
public ResourceSet saveNew(ResourceSet rs);
public ResourceSet getById(Long id);
}

View File

@ -155,6 +155,22 @@ public class JsonUtils {
return null;
}
}
/**
* Gets the value of the given member as a Long, null if it doesn't exist
*/
public static Long getAsLong(JsonObject o, String member) {
if (o.has(member)) {
JsonElement e = o.get(member);
if (e != null && e.isJsonPrimitive()) {
return e.getAsLong();
} else {
return null;
}
} else {
return null;
}
}
/**
* Gets the value of the given given member as a set of strings, null if it doesn't exist

View File

@ -27,4 +27,6 @@ public interface ResourceSetRepository {
public ResourceSet save(ResourceSet rs);
public ResourceSet getById(Long id);
}

View File

@ -42,4 +42,9 @@ public class JpaResourceSetRepository implements ResourceSetRepository {
return JpaUtil.saveOrUpdate(rs.getId(), em, rs);
}
@Override
public ResourceSet getById(Long id) {
return em.find(ResourceSet.class, id);
}
}

View File

@ -45,6 +45,11 @@ public class DefaultResourceSetService implements ResourceSetService {
return saved;
}
@Override
public ResourceSet getById(Long id) {
return repository.getById(id);
}