Implementing RR Service
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/information-system-model@129895 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
aa8ee151c3
commit
e0ca751908
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.impl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.embedded.Header;
|
||||
|
||||
/**
|
||||
|
@ -12,7 +14,7 @@ import org.gcube.informationsystem.model.embedded.Header;
|
|||
|
||||
public class HeaderImpl implements Header {
|
||||
|
||||
protected String id;
|
||||
protected UUID id;
|
||||
|
||||
protected String creator;
|
||||
|
||||
|
@ -21,11 +23,11 @@ public class HeaderImpl implements Header {
|
|||
protected Long lastUpdateTime;
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
public UUID getUUID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
protected void setID(String id){
|
||||
protected void setID(UUID id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.impl.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.entity.Context;
|
||||
|
||||
|
||||
|
@ -12,5 +14,27 @@ import org.gcube.informationsystem.model.entity.Context;
|
|||
*/
|
||||
public class ContextImpl extends EntityImpl implements Context {
|
||||
|
||||
protected UUID uuid;
|
||||
protected String name;
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUUID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.model.embedded;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.annotations.ISProperty;
|
||||
|
||||
/**
|
||||
|
@ -11,8 +13,10 @@ import org.gcube.informationsystem.model.annotations.ISProperty;
|
|||
*/
|
||||
public interface Header extends Embedded {
|
||||
|
||||
@ISProperty(readonly=true)
|
||||
public String getID();
|
||||
public static final String UUID_PROPERTY = "uuid";
|
||||
|
||||
@ISProperty(name=UUID_PROPERTY, readonly=true)
|
||||
public UUID getUUID();
|
||||
|
||||
@ISProperty(readonly=true)
|
||||
public String getCreator();
|
||||
|
|
|
@ -3,14 +3,28 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.model.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.annotations.ISProperty;
|
||||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public interface Context extends Entity {
|
||||
|
||||
public static final String CONTEXT_UUID_PROPERTY = "uuid";
|
||||
public static final String CONTEXT_NAME_PROPERTY = "name";
|
||||
|
||||
public static final String UUID_PROPERTY = "uuid";
|
||||
public static final String NAME_PROPERTY = "name";
|
||||
|
||||
@ISProperty(name=UUID_PROPERTY, mandatory=true, nullable=false)
|
||||
public UUID getUUID();
|
||||
|
||||
public void setUUID(UUID uuid);
|
||||
|
||||
|
||||
@ISProperty(name=NAME_PROPERTY, mandatory=true, nullable=false)
|
||||
public String getName();
|
||||
|
||||
public void setName(String name);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@ import org.gcube.informationsystem.model.embedded.Header;
|
|||
@Abstract
|
||||
public interface Entity {
|
||||
|
||||
@ISProperty
|
||||
public static final String HEADER_PROPERTY = "header";
|
||||
|
||||
@ISProperty(name=HEADER_PROPERTY)
|
||||
public Header getHeader();
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Type{
|
||||
|
||||
|
@ -110,6 +111,7 @@ public class Type{
|
|||
TYPES_BY_CLASS.put(Map.class, OType.EMBEDDEDMAP);
|
||||
TYPES_BY_CLASS.put(URI.class, OType.STRING);
|
||||
TYPES_BY_CLASS.put(URL.class, OType.STRING);
|
||||
TYPES_BY_CLASS.put(UUID.class, OType.STRING);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.types;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.gcube.informationsystem.model.annotations.Abstract;
|
||||
import org.gcube.informationsystem.model.embedded.Header;
|
||||
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -21,43 +17,6 @@ public class EntitySchemaDefinition {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(EntitySchemaDefinition.class);
|
||||
|
||||
public final static String NAME = "NAME";
|
||||
public final static String DESCRIPTION = "DESCRIPTION";
|
||||
|
||||
private static String getStaticStringFieldByName(Class<?> type, String fieldName, String defaultValue){
|
||||
Field field;
|
||||
try {
|
||||
field = type.getDeclaredField(NAME);
|
||||
return (String) field.get(null);
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static TypeDefinition createTypeDefinition(Class<?> type) {
|
||||
TypeDefinition typeDefinition = new TypeDefinition();
|
||||
|
||||
String name = getStaticStringFieldByName(type, NAME, type.getSimpleName());
|
||||
String description = getStaticStringFieldByName(type, DESCRIPTION, "");
|
||||
|
||||
logger.trace(name);
|
||||
logger.trace(description);
|
||||
|
||||
boolean isAbstract = false;
|
||||
if(type.isAnnotationPresent(Abstract.class)){
|
||||
isAbstract = true;
|
||||
}
|
||||
logger.trace("{}", isAbstract);
|
||||
|
||||
typeDefinition.name = name;
|
||||
typeDefinition.description = description;
|
||||
typeDefinition.abstractType = false;
|
||||
|
||||
logger.trace("retrieved type definition {} ",typeDefinition);
|
||||
|
||||
return typeDefinition;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Class<?> clz = Header.class;
|
||||
|
|
Loading…
Reference in New Issue