Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/// *******************************************************************************
// * Copyright (C) 2007, 2015:
// *
// * - Ferdinando Villa
// * - integratedmodelling.org
// * - any other authors listed in @author annotations
// *
// * All rights reserved. This file is part of the k.LAB software suite,
// * meant to enable modular, collaborative, integrated
// * development of interoperable data and model components. For
// * details, see http://integratedmodelling.org.
// *
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the Affero General Public License
// * Version 3 or any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but without any warranty; without even the implied warranty of
// * merchantability or fitness for a particular purpose. See the
// * Affero General Public License for more details.
// *
// * You should have received a copy of the Affero General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// * The license is also available at: https://www.gnu.org/licenses/agpl.html
// *******************************************************************************/
// package org.integratedmodelling.engine.services.local;
//
// import java.io.File;
// import java.util.ArrayList;
// import java.util.HashMap;
// import java.util.List;
// import java.util.Map;
//
// import org.integratedmodelling.api.metadata.IMetadata;
// import org.integratedmodelling.api.modelling.IObservation;
// import org.integratedmodelling.api.modelling.IScale;
// import org.integratedmodelling.api.modelling.IScale.Locator;
// import org.integratedmodelling.api.modelling.IState;
// import org.integratedmodelling.api.modelling.ISubject;
// import org.integratedmodelling.api.modelling.visualization.IMedia;
// import org.integratedmodelling.api.runtime.IContext;
// import org.integratedmodelling.api.runtime.ILegacySession;
// import org.integratedmodelling.api.services.IServiceCall;
// import org.integratedmodelling.api.services.annotations.Execute;
// import org.integratedmodelling.api.services.annotations.Prototype;
// import org.integratedmodelling.api.services.types.ILocalService;
// import org.integratedmodelling.api.services.types.ISessionService;
// import org.integratedmodelling.common.model.runtime.Scale;
// import org.integratedmodelling.common.network.Endpoints;
// import org.integratedmodelling.common.visualization.ColorMap;
// import org.integratedmodelling.common.visualization.Histogram;
// import org.integratedmodelling.common.visualization.Viewport;
// import org.integratedmodelling.engine.modelling.runtime.Subject;
// import org.integratedmodelling.engine.rest.RESTManager;
// import org.integratedmodelling.engine.visualization.VisualizationFactory;
// import org.integratedmodelling.exceptions.ThinklabException;
// import org.integratedmodelling.lang.IRemoteSerializable;
//
/// **
// * Inspection and maintenance of computed or computing contexts. Used by remote GUIs to
// * visualize ongoing results of computations or to retrieve previously serialized
// * contexts.
// *
// * API:
// *
// * cmd=load // load context from user repository
// * -> a serialized context descriptor with the ID
// * cmd=remove ctx=
// * -> removes the context from the active list, freeing the memory
// * cmd=persist ctx= remove=
// * -> persists the context and optionally removes it. Returns
// * the descriptor of the serialized context (TBD including
// * permanent ID).
// * cmd=list
// * -> two lists of numeric IDs: one tagged by "active"
// * containing descriptors of "live" contexts in order of
// * creation, and one tagged by "inactive" containing bare
// * descriptions of contexts that have timed out (structure
// * TBD) and including the location of the context in the
// * user repository if it was persisted.
// * Live contexts should also contain their current time to
// * expiration.
// * cmd=reset ctx=
// * -> reset the context by re-observing the root subject and
// * return its structure.
// * cmd=structure path= ctx=
// * -> context (sub-contexts and states). Each object is a
// * map with path, name, type and auxiliary info. TBD. For
// * states, the descriptor should contain the definition
// * of the representative observer. For sub-contexts, the
// * same structure is given, so the output is in fact a
// * tree. The root context path is identified by the slash
// * argument.
// * cmd=run ctx=
// * -> start temporal transitions. Immediately return ok/error
// * status while simulation is ongoing. Do nothing if finished.
// * cmd=step ctx=
// * -> run the next temporal transitions. Immediately return
// * ok/error status while simulation is ongoing. Do nothing
// * if finished.
// * cmd=status ctx= [after=]
// * -> a map containing structure (indexed by "structure"),
// * and the current status of the context. Also return a "timestamp"
// * with the time of last context change. If after is
// * passed, return a no-op with "ignore=true" unless the
// * last change in the context happened after the passed
// * timestamp.
// * cmd=get-media path= ctx= type= index= [attribute= [pN=]*] [break=]
// * -> descriptor for the visualization of the object
// * identified by at context . Result will have the MIME
// * type requested. Optionally the request may specify an attribute of the
// * object, such as the workflow graph for a task, the legend
// * or the colormap, and add parameters (starting at p0) to further specialize the target
// * or the result.
// * If break == true, set a breakpoint on this object, pausing temporal contexualization when it changes
/// until
// * run is called again.
// * cmd=get-data-summary path= ctx= type= [attribute= [pN=]*]
// * -> descriptor for the statistical summary of the object
// * identified by at context including an histogram of the data, data
// * type, color map, aggregated value and any other information relevant to content.
// * cmd=get-data-summary path= ctx= type= [attribute= [pN=]*]
// * -> data content of object
// * identified by at context including an histogram of the data and
// * any other information relevant to content.
// * cmd=get-data path= ctx=
// * -> descriptor for the visualization of the object
// * identified by .
// * cmd=export ctx= [path= format= {file= | remote=}]
// * -> handle to the exported version of the given path, using
// * the default format unless one is provided. If file is given, persist to
// * local file. Create a dataset for a subject (or if path is not passed),
// * an appropriate media (default or format-id) if a state.
// * cmd=image path= ctx= x= y=
// * -> an image representing the current values of the state
// * identified by fitting the passed dimensions.
// * cmd=history path= ctx=
// * -> a list of chronological steps describing each observation
// * made in this context. Each step contains the observed
// * objects, the provenance and dataflow diagrams, and the
// * start/end time. TBD logging etc.
// * cmd=breakpoint
// * -> pause and restart contextualization based on value of "action" parameter. Normally
// * only used to restart after a breakpoint was triggered by get-media.
// *
// * TODO/CHECK: added ILocalService so it can be used by JS-driven geomapper without having
// * to worry about headers for now.
// *
// * @author ferdinando.villa
// *
// */
// @Prototype(
// id = Endpoints.CONTEXT,
// args = {
// "# stateindex",
// Prototype.INT,
// "ctx",
// Prototype.INT,
// "# path",
// Prototype.TEXT,
// "# session",
// Prototype.TEXT,
// "# remove",
// Prototype.TEXT,
// "# format", Prototype.TEXT,
// "# x", Prototype.INT,
// "# y", Prototype.INT,
// "# after", Prototype.INT,
// "# viewport", Prototype.TEXT,
// "# break", Prototype.BOOLEAN,
// "# action", "stop|start",
// "# index", Prototype.TEXT,
// "# type", Prototype.TEXT,
// "# file", Prototype.TEXT,
// "# remote", Prototype.TEXT })
// public class Context implements ILocalService, ISessionService {
//
// @Execute(command = "status")
// public Object status(IServiceCall command) throws ThinklabException {
//
// org.integratedmodelling.engine.runtime.Context context = null;
// int ctx = -1;
// if (command.has("ctx")) {
// ctx = ((Number) (command.get("ctx"))).intValue();
// for (IContext c : command.getSession().getContexts()) {
// if (((org.integratedmodelling.engine.runtime.Context) c).getId() == ctx) {
// context = (org.integratedmodelling.engine.runtime.Context) c;
// break;
// }
// }
// }
//
// Map r = new HashMap();
// r.put("structure", getStructure((Subject) context.getSubject(), true));
// r.put("current", context.getCurrentTimeIndex());
// r.put("timestamp", context.getLastChangeTimestamp());
// r.put("id", context.getId());
// r.put("name", context.getName());
// return r;
// }
//
// @Execute(command = "persist", requires = { "file", "type" })
// public Object persist(IServiceCall command) throws ThinklabException {
//
// org.integratedmodelling.engine.runtime.Context context = null;
// int ctx = -1;
// if (command.has("ctx")) {
// ctx = ((Number) (command.get("ctx"))).intValue();
// for (IContext c : command.getSession().getContexts()) {
// if (((org.integratedmodelling.engine.runtime.Context) c).getId() == ctx) {
// context = (org.integratedmodelling.engine.runtime.Context) c;
// break;
// }
// }
// }
//
// String path = null;
// List