diff --git a/src/main/java/li/strolch/rest/inspector/Inspector.java b/src/main/java/li/strolch/rest/inspector/Inspector.java
index 846f2b14b..2d4d45aea 100644
--- a/src/main/java/li/strolch/rest/inspector/Inspector.java
+++ b/src/main/java/li/strolch/rest/inspector/Inspector.java
@@ -15,21 +15,37 @@
*/
package li.strolch.rest.inspector;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import li.strolch.agent.api.ComponentContainer;
import li.strolch.agent.api.OrderMap;
import li.strolch.agent.api.ResourceMap;
import li.strolch.agent.impl.StrolchRealm;
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Order;
+import li.strolch.model.Resource;
import li.strolch.persistence.api.StrolchTransaction;
+import li.strolch.rest.inspector.model.AgentOverview;
import li.strolch.rest.inspector.model.ElementMapOverview;
import li.strolch.rest.inspector.model.ElementMapType;
-import li.strolch.rest.inspector.model.ModelOverview;
+import li.strolch.rest.inspector.model.ElementMapsOverview;
+import li.strolch.rest.inspector.model.OrderOverview;
+import li.strolch.rest.inspector.model.RealmDetail;
+import li.strolch.rest.inspector.model.RealmOverview;
+import li.strolch.rest.inspector.model.ResourceOverview;
+import li.strolch.rest.inspector.model.StrolchElementOverview;
+import li.strolch.rest.inspector.model.TypeDetail;
+import li.strolch.rest.inspector.model.TypeOverview;
import ch.eitchnet.utils.dbc.DBC;
/**
@@ -38,30 +54,266 @@ import ch.eitchnet.utils.dbc.DBC;
@Path("strolch/inspector")
public class Inspector {
+ /**
+ *
+ * Root path of the inspector
+ *
+ *
+ *
+ * Returns the root element, which is an overview of the configured realms
+ *
+ *
+ * @return the root element, which is an overview of the configured realms
+ *
+ * @see AgentOverview
+ */
@GET
@Produces(MediaType.APPLICATION_JSON)
- public Response getRoot(@QueryParam("realm") String realm) {
+ public Response getAgent() {
+
+ ComponentContainer container = AgentRef.getInstance().getContainer();
+ Set realmNames = container.getRealmNames();
+ List realmOverviews = new ArrayList<>(realmNames.size());
+ for (String realmName : realmNames) {
+
+ StrolchRealm realm = container.getRealm(realmName);
+ try (StrolchTransaction tx = realm.openTx()) {
+ long size = 0;
+ size += realm.getResourceMap().querySize(tx);
+ size += realm.getOrderMap().querySize(tx);
+ RealmOverview realmOverview = new RealmOverview(realmName, size);
+ realmOverviews.add(realmOverview);
+ }
+ }
+
+ AgentOverview agentOverview = new AgentOverview(realmOverviews);
+ GenericEntity entity = new GenericEntity(agentOverview, AgentOverview.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ /**
+ *
+ * Realm inspector
+ *
+ *
+ *
+ * Returns the overview of a specific relam
+ *
+ *
+ * @param realm
+ * the realm for which the overview is to be returned
+ *
+ * @return the overview of a specific relam
+ *
+ * @see RealmDetail
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}")
+ public Response getRealm(@PathParam("realm") String realm) {
DBC.PRE.assertNotEmpty("Realm must be set!", realm);
StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
- ModelOverview modelOverview = new ModelOverview();
-
+ List elementMapOverviews = new ArrayList<>(2);
try (StrolchTransaction tx = strolchRealm.openTx()) {
ResourceMap resourceMap = strolchRealm.getResourceMap();
- ElementMapOverview resourceOverview = new ElementMapOverview(ElementMapType.RESOURCE);
+ ElementMapsOverview resourceOverview = new ElementMapsOverview(ElementMapType.RESOURCE);
resourceOverview.setNrOfElements(resourceMap.querySize(tx));
resourceOverview.setTypes(resourceMap.getTypes(tx));
- modelOverview.getElementMapOverviews().add(resourceOverview);
+ elementMapOverviews.add(resourceOverview);
OrderMap orderMap = strolchRealm.getOrderMap();
- ElementMapOverview orderOverview = new ElementMapOverview(ElementMapType.ORDER);
+ ElementMapsOverview orderOverview = new ElementMapsOverview(ElementMapType.ORDER);
orderOverview.setNrOfElements(orderMap.querySize(tx));
orderOverview.setTypes(orderMap.getTypes(tx));
- modelOverview.getElementMapOverviews().add(orderOverview);
+ elementMapOverviews.add(orderOverview);
}
- GenericEntity entity = new GenericEntity(modelOverview, ModelOverview.class) {
+ RealmDetail modelOverview = new RealmDetail(elementMapOverviews);
+ GenericEntity entity = new GenericEntity(modelOverview, RealmDetail.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ /**
+ *
+ * Resource inspector
+ *
+ *
+ * Returns an overview of the {@link Resource Resources}. This is a list of all the types and the size each type has
+ *
+ *
+ * @param realm
+ * the realm for which the resource overview is to be returned
+ *
+ * @return an overview of the {@link Resource Resources}. This is a list of all the types and the size each type has
+ *
+ * @see ElementMapOverview
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}/resource")
+ public Response getResourcesOverview(@PathParam("realm") String realm) {
+ DBC.PRE.assertNotEmpty("Realm must be set!", realm);
+ StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
+
+ ElementMapOverview resourcesOverview;
+ try (StrolchTransaction tx = strolchRealm.openTx()) {
+ ResourceMap resourceMap = tx.getResourceMap();
+ Set types = resourceMap.getTypes(tx);
+ List typeOverviews = new ArrayList<>(types.size());
+ for (String type : types) {
+ long size = resourceMap.querySize(tx, type);
+ TypeOverview typeOverview = new TypeOverview(type, size);
+ typeOverviews.add(typeOverview);
+ }
+
+ resourcesOverview = new ElementMapOverview(ElementMapType.RESOURCE.getName(), typeOverviews);
+ }
+
+ GenericEntity entity = new GenericEntity(resourcesOverview,
+ ElementMapOverview.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ /**
+ *
+ * Order inspector
+ *
+ *
+ * Returns an overview of the {@link Order Orderss}. This is a list of all the types and the size each type has
+ *
+ *
+ * @param realm
+ * the realm for which the order overview is to be returned
+ *
+ * @return an overview of the {@link Order Orders}. This is a list of all the types and the size each type has
+ *
+ * @see ElementMapOverview
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}/order")
+ public Response getOrdersOverview(@PathParam("realm") String realm) {
+ DBC.PRE.assertNotEmpty("Realm must be set!", realm);
+ StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
+
+ ElementMapOverview ordersOverview;
+ try (StrolchTransaction tx = strolchRealm.openTx()) {
+ OrderMap orderMap = tx.getOrderMap();
+ Set types = orderMap.getTypes(tx);
+ List typeOverviews = new ArrayList<>(types.size());
+ for (String type : types) {
+ long size = orderMap.querySize(tx, type);
+ TypeOverview typeOverview = new TypeOverview(type, size);
+ typeOverviews.add(typeOverview);
+ }
+
+ ordersOverview = new ElementMapOverview(ElementMapType.ORDER.getName(), typeOverviews);
+ }
+
+ GenericEntity entity = new GenericEntity(ordersOverview,
+ ElementMapOverview.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ // TODO for the get element type details, we should not simply query all objects, but rather find a solution to query only the id, name, type and date, state for the order
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}/resource/{type}")
+ public Response getResourceTypeDetails(@PathParam("realm") String realm, @PathParam("type") String type) {
+ DBC.PRE.assertNotEmpty("Realm must be set!", realm);
+ StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
+
+ TypeDetail typeDetail;
+ try (StrolchTransaction tx = strolchRealm.openTx()) {
+ List byType = tx.getResourceMap().getElementsBy(tx, type);
+ List elementOverviews = new ArrayList<>(byType.size());
+ for (Resource resource : byType) {
+ ResourceOverview resourceOverview = new ResourceOverview(resource.getId(), resource.getName(),
+ resource.getType());
+ elementOverviews.add(resourceOverview);
+ }
+ typeDetail = new TypeDetail(type, elementOverviews);
+ }
+
+ GenericEntity entity = new GenericEntity(typeDetail, TypeDetail.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}/order/{type}")
+ public Response getOrderTypeDetails(@PathParam("realm") String realm, @PathParam("type") String type) {
+ DBC.PRE.assertNotEmpty("Realm must be set!", realm);
+ StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
+
+ TypeDetail typeDetail;
+ try (StrolchTransaction tx = strolchRealm.openTx()) {
+ List byType = tx.getOrderMap().getElementsBy(tx, type);
+ List elementOverviews = new ArrayList<>(byType.size());
+ for (Order order : byType) {
+ OrderOverview orderOverview = new OrderOverview(order.getId(), order.getName(), order.getType(),
+ order.getDate(), order.getState());
+ elementOverviews.add(orderOverview);
+ }
+ typeDetail = new TypeDetail(type, elementOverviews);
+ }
+
+ GenericEntity entity = new GenericEntity(typeDetail, TypeDetail.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}/resource/{type}/{id}")
+ public Response getResource(@PathParam("realm") String realm, @PathParam("type") String type,
+ @PathParam("id") String id) {
+ DBC.PRE.assertNotEmpty("Realm must be set!", realm);
+ StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
+
+ Resource resource;
+ try (StrolchTransaction tx = strolchRealm.openTx()) {
+ resource = tx.getResourceMap().getBy(tx, type, id);
+ }
+ if (resource == null) {
+ throw new StrolchException("No Resource exists for " + type + "/" + id);
+ }
+
+ ResourceOverview resourceOverview = new ResourceOverview(resource.getId(), resource.getName(),
+ resource.getType());
+ GenericEntity entity = new GenericEntity(resourceOverview,
+ ResourceOverview.class) {
+ };
+ return Response.ok().entity(entity).build();
+ }
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{realm}/order/{type}/{id}")
+ public Response getOrder(@PathParam("realm") String realm, @PathParam("type") String type,
+ @PathParam("id") String id) {
+ DBC.PRE.assertNotEmpty("Realm must be set!", realm);
+ StrolchRealm strolchRealm = AgentRef.getInstance().getContainer().getRealm(realm);
+
+ Order order;
+ try (StrolchTransaction tx = strolchRealm.openTx()) {
+ order = tx.getOrderMap().getBy(tx, type, id);
+ }
+ if (order == null) {
+ throw new StrolchException("No Order exists for " + type + "/" + id);
+ }
+
+ OrderOverview orderOverview = new OrderOverview(order.getId(), order.getName(), order.getType(),
+ order.getDate(), order.getState());
+ GenericEntity entity = new GenericEntity(orderOverview, OrderOverview.class) {
};
return Response.ok().entity(entity).build();
}
diff --git a/src/main/java/li/strolch/rest/inspector/model/AgentOverview.java b/src/main/java/li/strolch/rest/inspector/model/AgentOverview.java
new file mode 100644
index 000000000..b39d02640
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/AgentOverview.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "Agent")
+public class AgentOverview {
+
+ @XmlElement(name = "realms")
+ private List realms;
+
+ public AgentOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ public AgentOverview(List realms) {
+ this.realms = realms;
+ }
+
+ /**
+ * @return the realms
+ */
+ public List getRealms() {
+ return this.realms;
+ }
+
+ /**
+ * @param realms
+ * the realms to set
+ */
+ public void setRealms(List realms) {
+ this.realms = realms;
+ }
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/ElementMapOverview.java b/src/main/java/li/strolch/rest/inspector/model/ElementMapOverview.java
index f59878e0a..5967a3855 100644
--- a/src/main/java/li/strolch/rest/inspector/model/ElementMapOverview.java
+++ b/src/main/java/li/strolch/rest/inspector/model/ElementMapOverview.java
@@ -15,102 +15,84 @@
*/
package li.strolch.rest.inspector.model;
-import java.util.Set;
+import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @author Robert von Burg
*/
@XmlAccessorType(XmlAccessType.NONE)
-@XmlRootElement
+@XmlRootElement(name = "ElementMap")
public class ElementMapOverview {
- @XmlAttribute(name = "name")
- private String name;
-
- @XmlAttribute(name = "elementMapType")
- private ElementMapType elementMapType;
-
- @XmlAttribute(name = "types")
- private Set types;
-
- @XmlAttribute(name = "nrOfElements")
- private long nrOfElements;
+ @XmlAttribute(name = "elementMapName")
+ private String elementMapName;
+ @XmlAttribute(name = "size")
+ private long size;
+ @XmlElement(name = "types", type = TypeOverview.class)
+ private List typeOverviews;
public ElementMapOverview() {
- // empty constructor for JAXB
+ // no-arg constructor for JAXB
}
/**
- * @param elementMapType
+ * @param elementMapName
+ * @param typeOverviews
*/
- public ElementMapOverview(ElementMapType elementMapType) {
- super();
- this.elementMapType = elementMapType;
- this.name = elementMapType.getName();
+ public ElementMapOverview(String elementMapName, List typeOverviews) {
+ this.elementMapName = elementMapName;
+ this.typeOverviews = typeOverviews;
+ this.size = this.typeOverviews.size();
}
/**
- * @return the name
+ * @return the elementMapName
*/
- public String getName() {
- return this.name;
+ public String getElementMapName() {
+ return this.elementMapName;
}
/**
- * @param name
- * the name to set
+ * @param elementMapName
+ * the elementMapName to set
*/
- public void setName(String name) {
- this.name = name;
+ public void setElementMapName(String elementMapName) {
+ this.elementMapName = elementMapName;
}
/**
- * @return the elementMapType
+ * @return the size
*/
- public ElementMapType getElementMapType() {
- return this.elementMapType;
+ public long getSize() {
+ return this.size;
}
/**
- * @param elementMapType
- * the elementMapType to set
+ * @param size
+ * the size to set
*/
- public void setElementMapType(ElementMapType elementMapType) {
- this.elementMapType = elementMapType;
+ public void setSize(long size) {
+ this.size = size;
}
/**
- * @return the types
+ * @return the typeOverviews
*/
- public Set getTypes() {
- return this.types;
+ public List getTypeOverviews() {
+ return this.typeOverviews;
}
/**
- * @param types
- * the types to set
+ * @param typeOverviews
+ * the typeOverviews to set
*/
- public void setTypes(Set types) {
- this.types = types;
- }
-
- /**
- * @return the nrOfElements
- */
- public long getNrOfElements() {
- return this.nrOfElements;
- }
-
- /**
- * @param nrOfElements
- * the nrOfElements to set
- */
- public void setNrOfElements(long nrOfElements) {
- this.nrOfElements = nrOfElements;
+ public void setTypeOverviews(List typeOverviews) {
+ this.typeOverviews = typeOverviews;
}
}
diff --git a/src/main/java/li/strolch/rest/inspector/model/ElementMapsOverview.java b/src/main/java/li/strolch/rest/inspector/model/ElementMapsOverview.java
new file mode 100644
index 000000000..4a5b55dcb
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/ElementMapsOverview.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "ElementMaps")
+public class ElementMapsOverview {
+
+ @XmlAttribute(name = "name")
+ private String name;
+
+ @XmlAttribute(name = "elementMapType")
+ private ElementMapType elementMapType;
+
+ @XmlAttribute(name = "nrOfElements")
+ private long nrOfElements;
+
+ @XmlElement(name = "types")
+ private Set types;
+
+ public ElementMapsOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ /**
+ * @param elementMapType
+ */
+ public ElementMapsOverview(ElementMapType elementMapType) {
+ super();
+ this.elementMapType = elementMapType;
+ this.name = elementMapType.getName();
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the elementMapType
+ */
+ public ElementMapType getElementMapType() {
+ return this.elementMapType;
+ }
+
+ /**
+ * @param elementMapType
+ * the elementMapType to set
+ */
+ public void setElementMapType(ElementMapType elementMapType) {
+ this.elementMapType = elementMapType;
+ }
+
+ /**
+ * @return the types
+ */
+ public Set getTypes() {
+ return this.types;
+ }
+
+ /**
+ * @param types
+ * the types to set
+ */
+ public void setTypes(Set types) {
+ this.types = types;
+ }
+
+ /**
+ * @return the nrOfElements
+ */
+ public long getNrOfElements() {
+ return this.nrOfElements;
+ }
+
+ /**
+ * @param nrOfElements
+ * the nrOfElements to set
+ */
+ public void setNrOfElements(long nrOfElements) {
+ this.nrOfElements = nrOfElements;
+ }
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/OrderOverview.java b/src/main/java/li/strolch/rest/inspector/model/OrderOverview.java
new file mode 100644
index 000000000..256a82c29
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/OrderOverview.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import li.strolch.model.State;
+import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "Order")
+public class OrderOverview extends StrolchElementOverview {
+
+ @XmlAttribute(name = "date")
+ private String date;
+ @XmlAttribute(name = "state")
+ private State state;
+
+ public OrderOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ /**
+ * @param id
+ * @param name
+ * @param type
+ */
+ public OrderOverview(String id, String name, String type, Date date, State state) {
+ super(id, name, type);
+ this.state = state;
+ this.date = ISO8601FormatFactory.getInstance().formatDate(date);
+ }
+
+ /**
+ * @return the date
+ */
+ public String getDate() {
+ return this.date;
+ }
+
+ /**
+ * @param date
+ * the date to set
+ */
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ /**
+ * @return the state
+ */
+ public State getState() {
+ return this.state;
+ }
+
+ /**
+ * @param state
+ * the state to set
+ */
+ public void setState(State state) {
+ this.state = state;
+ }
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/ModelOverview.java b/src/main/java/li/strolch/rest/inspector/model/RealmDetail.java
similarity index 71%
rename from src/main/java/li/strolch/rest/inspector/model/ModelOverview.java
rename to src/main/java/li/strolch/rest/inspector/model/RealmDetail.java
index 52df23cc2..a61ac7c3e 100644
--- a/src/main/java/li/strolch/rest/inspector/model/ModelOverview.java
+++ b/src/main/java/li/strolch/rest/inspector/model/RealmDetail.java
@@ -15,7 +15,6 @@
*/
package li.strolch.rest.inspector.model;
-import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -27,20 +26,24 @@ import javax.xml.bind.annotation.XmlRootElement;
* @author Robert von Burg
*/
@XmlAccessorType(XmlAccessType.NONE)
-@XmlRootElement
-public class ModelOverview {
+@XmlRootElement(name = "Realm")
+public class RealmDetail {
- @XmlElement
- private List elementMapOverviews;
+ @XmlElement(name = "ElementMaps")
+ private List elementMapOverviews;
- public ModelOverview() {
- this.elementMapOverviews = new ArrayList<>();
+ public RealmDetail() {
+ // no-arg constructor for JAXB
+ }
+
+ public RealmDetail(List elementMapOverviews) {
+ this.elementMapOverviews = elementMapOverviews;
}
/**
* @return the elementMapOverviews
*/
- public List getElementMapOverviews() {
+ public List getElementMapOverviews() {
return this.elementMapOverviews;
}
@@ -48,7 +51,7 @@ public class ModelOverview {
* @param elementMapOverviews
* the elementMapOverviews to set
*/
- public void setElementMapOverviews(List elementMapOverviews) {
+ public void setElementMapOverviews(List elementMapOverviews) {
this.elementMapOverviews = elementMapOverviews;
}
}
diff --git a/src/main/java/li/strolch/rest/inspector/model/RealmOverview.java b/src/main/java/li/strolch/rest/inspector/model/RealmOverview.java
new file mode 100644
index 000000000..0566fef0d
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/RealmOverview.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "RealmOverview")
+public class RealmOverview {
+
+ @XmlAttribute(name = "realmName")
+ private String realmName;
+ @XmlAttribute(name = "size")
+ private long size;
+
+ public RealmOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ public RealmOverview(String realmName, long size) {
+ this.realmName = realmName;
+ this.size = size;
+
+ }
+
+ /**
+ * @return the realmName
+ */
+ public String getRealmName() {
+ return this.realmName;
+ }
+
+ /**
+ * @param realmName
+ * the realmName to set
+ */
+ public void setRealmName(String realmName) {
+ this.realmName = realmName;
+ }
+
+ /**
+ * @return the size
+ */
+ public long getSize() {
+ return this.size;
+ }
+
+ /**
+ * @param size
+ * the size to set
+ */
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/ResourceOverview.java b/src/main/java/li/strolch/rest/inspector/model/ResourceOverview.java
new file mode 100644
index 000000000..35bab97ea
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/ResourceOverview.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlRootElement(name = "Resource")
+public class ResourceOverview extends StrolchElementOverview {
+
+ public ResourceOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ /**
+ * @param id
+ * @param name
+ * @param type
+ */
+ public ResourceOverview(String id, String name, String type) {
+ super(id, name, type);
+ }
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/StrolchElementOverview.java b/src/main/java/li/strolch/rest/inspector/model/StrolchElementOverview.java
new file mode 100644
index 000000000..1140ab05a
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/StrolchElementOverview.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlSeeAlso({ ResourceOverview.class, OrderOverview.class })
+public abstract class StrolchElementOverview {
+
+ @XmlAttribute(name = "id", required = true)
+ private String id;
+ @XmlAttribute(name = "name", required = true)
+ private String name;
+ @XmlAttribute(name = "type", required = true)
+ private String type;
+
+ public StrolchElementOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ /**
+ * @param id
+ * @param name
+ * @param type
+ */
+ public StrolchElementOverview(String id, String name, String type) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.type = type;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/TypeDetail.java b/src/main/java/li/strolch/rest/inspector/model/TypeDetail.java
new file mode 100644
index 000000000..6f97a2f23
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/TypeDetail.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "Types")
+public class TypeDetail {
+
+ @XmlAttribute(name = "type")
+ private String type;
+
+ @XmlElements(value = { @XmlElement(name = "Orders", type = OrderOverview.class),
+ @XmlElement(name = "Resources", type = ResourceOverview.class) })
+ private List elementOverviews;
+
+ public TypeDetail() {
+ // no-arg constructor for JAXB
+ }
+
+ /**
+ * @param type
+ * @param elementOverviews
+ */
+ public TypeDetail(String type, List elementOverviews) {
+ super();
+ this.type = type;
+ this.elementOverviews = elementOverviews;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the elementOverviews
+ */
+ public List getElementOverviews() {
+ return this.elementOverviews;
+ }
+
+ /**
+ * @param elementOverviews
+ * the elementOverviews to set
+ */
+ public void setElementOverviews(List elementOverviews) {
+ this.elementOverviews = elementOverviews;
+ }
+}
diff --git a/src/main/java/li/strolch/rest/inspector/model/TypeOverview.java b/src/main/java/li/strolch/rest/inspector/model/TypeOverview.java
new file mode 100644
index 000000000..005620bf2
--- /dev/null
+++ b/src/main/java/li/strolch/rest/inspector/model/TypeOverview.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2013 Robert von Burg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package li.strolch.rest.inspector.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Robert von Burg
+ */
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "Types")
+public class TypeOverview {
+
+ @XmlAttribute(name = "type")
+ private String type;
+
+ @XmlAttribute(name = "size")
+ private long size;
+
+ public TypeOverview() {
+ // no-arg constructor for JAXB
+ }
+
+ /**
+ * @param type
+ * @param size
+ */
+ public TypeOverview(String type, long size) {
+ this.type = type;
+ this.size = size;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the size
+ */
+ public long getSize() {
+ return this.size;
+ }
+
+ /**
+ * @param size
+ * the size to set
+ */
+ public void setSize(long size) {
+ this.size = size;
+ }
+}