本文整理汇总了Java中i5.las2peer.api.Context类的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于i5.las2peer.api包,在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getServiceNameVersion
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* This method allows to retrieve the service name version.
*
* @return Response with service name version as a JSON object.
*/
@GET
@Path("/version")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "This method allows to retrieve the service name version.")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns service name version"),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal server problems")
})
public Response getServiceNameVersion() throws ActivityTrackerException {
try {
String serviceNameVersion = Context.getCurrent().getService().getAgent().getServiceNameVersion().toString();
return Response.ok("{\"version\": \"" + serviceNameVersion + "\"}").build();
} catch (AgentNotKnownException ex) {
ActivityTrackerException atException = ExceptionHandler.getInstance().convert(ex, ExceptionLocation.ACTIVITYTRACKERSERVICE, ErrorCode.UNKNOWN, ex.getMessage());
L2pLogger.logEvent(NodeObserver.Event.SERVICE_ERROR, Context.getCurrent().getMainAgent(), "Get service name version failed");
service.logger.warning(atException.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionHandler.getInstance().toJSON(atException)).build();
}
}
开发者ID:rwth-acis,项目名称:las2peer-ActivityTracker,代码行数:25,代码来源:ActivityTrackerService.java
示例2: getServiceNameVersion
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* This method allows to retrieve the service name version.
*
* @return Response with service name version as a JSON object.
*/
@GET
@Path("/version")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "This method allows to retrieve the service name version.")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns service name version"),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal server problems")
})
public Response getServiceNameVersion() {
try {
String serviceNameVersion = Context.getCurrent().getService().getAgent().getServiceNameVersion().toString();
return Response.ok("{\"version\": \"" + serviceNameVersion + "\"}").build();
} catch (AgentNotKnownException ex) {
BazaarException bex = ExceptionHandler.getInstance().convert(ex, ExceptionLocation.BAZAARSERVICE, ErrorCode.UNKNOWN, ex.getMessage());
L2pLogger.logEvent(NodeObserver.Event.SERVICE_ERROR, Context.getCurrent().getMainAgent(), "Get service name version failed");
bazaarService.logger.warning(bex.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionHandler.getInstance().toJSON(bex)).build();
}
}
开发者ID:rwth-acis,项目名称:RequirementsBazaar,代码行数:25,代码来源:BazaarService.java
示例3: notifications
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* This method sends all notifications (emails) in the waiting queue. Run this method before shutting down Requirements Bazaar.
*
* @return Response
*/
@POST
@Path("/notifications")
@ApiOperation(value = "This method sends all notifications (emails) in the waiting queue. Run this method before shutting down Requirements Bazaar.")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Notifications send"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized"),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal server problems")
})
public Response sendNotifications() {
// TODO: Use authorization scopes to limit users who can run this method to admins
try {
bazaarService.notificationDispatcher.run();
return Response.status(Response.Status.CREATED).build();
} catch (Exception ex) {
BazaarException bex = ExceptionHandler.getInstance().convert(ex, ExceptionLocation.BAZAARSERVICE, ErrorCode.UNKNOWN, ex.getMessage());
L2pLogger.logEvent(NodeObserver.Event.SERVICE_ERROR, Context.getCurrent().getMainAgent(), "Send Notifications failed");
bazaarService.logger.warning(bex.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionHandler.getInstance().toJSON(bex)).build();
}
}
开发者ID:rwth-acis,项目名称:RequirementsBazaar,代码行数:26,代码来源:BazaarService.java
示例4: getActiveUserInfo
import i5.las2peer.api.Context; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private JSONObject getActiveUserInfo() throws ParseException {
if (Context.getCurrent().getMainAgent() instanceof UserAgent) {
UserAgent me = (UserAgent) Context.getCurrent().getMainAgent();
JSONObject o = new JSONObject();
if (Context.get().getMainAgent() instanceof AnonymousAgent) {
o.put("sub", "anonymous");
} else {
String md5ide = new String("" + me.getIdentifier());
o.put("sub", md5ide);
}
return o;
} else {
return new JSONObject();
}
}
开发者ID:rwth-acis,项目名称:mobsos-surveys,代码行数:18,代码来源:SurveyService.java
示例5: getResultSet
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Execute an sql-query and returns the corresponding result set. <br>
* The actual database access is done here (by calling sqlDatabase.executeQuery).
*
* @param sqlQuery the query
* @param databaseKey the key of the database
*
* @return ResultSet of the database query
* @throws ServiceException
* @throws SQLException
*/
private ResultSet getResultSet(Connection con, SQLDatabase sqlDatabase, String sqlQuery, String databaseKey)
throws ServiceException, SQLException {
try {
ResultSet resultSet = sqlDatabase.executeQuery(con, sqlQuery);
if (resultSet == null) {
throw new Exception("Failed to get an result set from the desired database!");
}
return resultSet;
} catch (SQLException ex) {
throw ex;
} catch (Exception e) {
Context.get().monitorEvent(this, MonitoringEvent.SERVICE_ERROR, e.toString());
System.out.println(e.getMessage());
throw new ServiceException("Exception in getResultSet", e);
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:29,代码来源:QueryVisualizationService.java
示例6: saveQuery
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Saves a query. <br>
*
* @param queryStatement a String containing the query
* @param databaseKey the key to the database
* @param useCache if true, a cached result is returned (if available) instead of performing the query again
* @param modificationTypeIndex the desired modification function
* @param visualizationTypeIndex the desired visualization
* @param visualizationParamaters an array of additional parameters for the visualization, including title, height
* and weight
*
* @return The id of the saved query as a String
*/
private String saveQuery(String queryStatement, String[] queryParameters, String databaseKey, boolean useCache,
int modificationTypeIndex, VisualizationType visualizationTypeIndex, String[] visualizationParamaters) {
SQLDatabase database = null;
Query query = null;
String queryKey = ""; // If empty, the query generates a new one
try {
String user = Context.get().getMainAgent().getIdentifier();
SQLDatabaseManager databaseManager = databaseManagerMap.get(user);
QueryManager queryManager = queryManagerMap.get(user);
database = databaseManager.getDatabaseInstance(databaseKey);
query = new Query(Context.getCurrent().getMainAgent().getIdentifier(), database.getJdbcInfo(),
database.getUser(), database.getPassword(), databaseKey, database.getDatabase(), database.getHost(),
database.getPort(), queryStatement, queryParameters, useCache, modificationTypeIndex,
visualizationTypeIndex, visualizationParamaters, queryKey);
queryManager.storeQuery(query);
} catch (Exception e) {
Context.get().monitorEvent(this, MonitoringEvent.SERVICE_ERROR, e.toString());
return VisualizationException.getInstance().generate(e, "An error occured while trying to save a Query!");
}
Context.get().monitorEvent(this, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_17, "" + query.getQueryStatement(),
true);
return query.getKey();
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:39,代码来源:QueryVisualizationService.java
示例7: QueryManager
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Constructor
*
* @param service instance of the qv service
* @param dbm Database
*/
public QueryManager(QueryVisualizationService service, SQLDatabase dbm) {
storageDatabase = dbm;
this.service = service;
// get the user's security object which contains the database
// information
Query[] settings = null;
try {
Connection c = storageDatabase.getConnection();
PreparedStatement p = c.prepareStatement("SELECT * FROM QUERIES WHERE USER = ?;");
p.setString(1, Context.get().getMainAgent().getIdentifier());
ResultSet databases = p.executeQuery();
settings = Query.fromResultSet(databases);
c.close();
} catch (Exception e) {
logMessage("Failed to get the users' SQL settings. " + e.getMessage());
}
for (Query setting : settings) {
userQueryMap.put(setting.getKey(), setting);
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:30,代码来源:QueryManager.java
示例8: databaseDeleted
import i5.las2peer.api.Context; //导入依赖的package包/类
public void databaseDeleted(String dbKey) {
String db;
try {
db = service.databaseManagerMap.get(Context.get().getMainAgent().getIdentifier()).getDatabaseInstance(dbKey)
.getDatabase();
} catch (Exception e1) {
return;
}
for (Query q : userQueryMap.values()) {
if (q.getDatabaseName().equals(db)) {
try {
removeQ(q.getKey());
} catch (Exception e) {
}
}
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:18,代码来源:QueryManager.java
示例9: removeQ
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Remove given database from the database
*
* @param queryKey Key of the query which will be removed
*/
public void removeQ(String queryKey) {
try {
Connection c = storageDatabase.getConnection();
PreparedStatement s = c.prepareStatement("DELETE FROM `QUERIES` WHERE ((`KEY` = ? AND `USER` = ?))");
s.setString(1, queryKey);
s.setString(2, Context.get().getMainAgent().getIdentifier());
s.executeUpdate();
c.close();
} catch (Exception e) {
logMessage("Error removing the Query! " + e);
System.out.println("QV critical:");
e.printStackTrace();
} finally {
userQueryMap.remove(queryKey);
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:23,代码来源:QueryManager.java
示例10: setStateFromXml
import i5.las2peer.api.Context; //导入依赖的package包/类
public void setStateFromXml(String arg0) throws MalformedXMLException {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(arg0);
int childrenCount = doc.getChildNodes().item(0).getChildNodes().getLength();
doc.getDocumentElement().normalize();
Element elm = doc.getDocumentElement();
if (childrenCount != 1) {
throw new Exception("Wrong number of children! " + childrenCount + " instead of 1!");
}
this.key = elm.getAttribute("key");
this.query = elm.getAttribute("query");
this.databaseKey = elm.getAttribute("databaseKey");
} catch (Exception e) {
Context.get().monitorEvent(this, MonitoringEvent.SERVICE_ERROR,
"SQLFilterSettings, setStateFromXML: " + e.getMessage());
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:24,代码来源:SQLFilterSettings.java
示例11: addFilter
import i5.las2peer.api.Context; //导入依赖的package包/类
public boolean addFilter(String databaseKey, String filterName, String sqlQuery) throws Exception {
StringPair filterKey = new StringPair(databaseKey, filterName);
try {
// TODO: sanity checks for the parameters
if (filterExists(databaseKey, filterName)) {
throw new Exception("Filter " + filterKey + " already exists!");
}
Connection c = storageDatabase.getConnection();
SQLFilterSettings filterSettings = new SQLFilterSettings(databaseKey, filterName, sqlQuery);
PreparedStatement p = c.prepareStatement(
"INSERT INTO `FILTERS` (`KEY`, `QUERY`, `USER`, `DB_KEY`) VALUES (?, ?, ?, ?);");
p.setString(1, filterName);
p.setString(2, sqlQuery);
p.setString(3, Context.get().getMainAgent().getIdentifier());
p.setString(4, databaseKey);
p.executeUpdate();
userFilterMap.put(filterSettings.getKey(), filterSettings);
c.close();
return true;
} catch (Exception e) {
e.printStackTrace();
logMessage(e.getMessage());
throw e;
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:27,代码来源:SQLFilterManager.java
示例12: initializeUser
import i5.las2peer.api.Context; //导入依赖的package包/类
private boolean initializeUser() {
try {
Connection c = storageDatabase.getConnection();
PreparedStatement p = c.prepareStatement("SELECT DISTINCT ID FROM USERS WHERE ID = ?");
p.setString(1, Context.get().getMainAgent().getIdentifier());
ResultSet s = p.executeQuery();
if (!s.next()) {
p = c.prepareStatement("REPLACE INTO USERS (ID) VALUES (?)");
p.setString(1, Context.get().getMainAgent().getIdentifier());
p.executeUpdate();
}
c.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:19,代码来源:SQLDatabaseManager.java
示例13: SQLDatabaseManager
import i5.las2peer.api.Context; //导入依赖的package包/类
public SQLDatabaseManager(Service service, SQLDatabase storageDatabase) {
this.storageDatabase = storageDatabase;
// get the user's security object which contains the database
// information
initializeUser();
SQLDatabaseSettings[] settings = null;
try {
Connection c = storageDatabase.getConnection();
PreparedStatement p = c.prepareStatement("SELECT * FROM DATABASE_CONNECTIONS WHERE USER = ?;");
p.setString(1, Context.get().getMainAgent().getIdentifier());
ResultSet databases = p.executeQuery();
settings = SQLDatabaseSettings.fromResultSet(databases);
c.close();
} catch (Exception e) {
logMessage("Failed to get the users' SQL settings. " + e.getMessage());
}
for (SQLDatabaseSettings setting : settings) {
userDatabaseMap.put(setting.getKey(), setting);
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:25,代码来源:SQLDatabaseManager.java
示例14: removeDB
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Remove given database from the database
*/
private void removeDB(String databaseKey) throws SQLException {
try {
Connection c = storageDatabase.getConnection();
PreparedStatement s = c
.prepareStatement("DELETE FROM `DATABASE_CONNECTIONS` WHERE `KEY` = ? AND `USER` = ?");
s.setString(1, databaseKey);
s.setString(2, Context.get().getMainAgent().getIdentifier());
s.executeUpdate();
c.close();
} catch (Exception e) {
logMessage("Error removing the Database! " + e);
System.out.println("QV critical:");
e.printStackTrace();
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:20,代码来源:SQLDatabaseManager.java
示例15: executeQuery
import i5.las2peer.api.Context; //导入依赖的package包/类
public ResultSet executeQuery(Connection con, String sqlQuery) throws Exception {
// I don't allow escape characters...
// at least some very basic escape checking
// (I don't think it is sufficient for a real attack though....)
sqlQuery = sqlQuery.replace("\\", "\\\\");
sqlQuery = sqlQuery.replace("\0", "\\0");
sqlQuery = sqlQuery.replace(";", "");
try {
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery(sqlQuery);
return resultSet;
} catch (SQLException ex) {
System.out.println(ex.getMessage());
throw ex;
} catch (Exception e) {
System.out.println(e.getMessage());
Context.get().monitorEvent(this, MonitoringEvent.SERVICE_ERROR, e.toString());
throw e;
}
}
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:23,代码来源:SQLDatabase.java
示例16: getFile
import i5.las2peer.api.Context; //导入依赖的package包/类
public String getFile(String file) {
try {
// RMI call
Object result = Context.get().invoke("[email protected]" + fileServiceVersion,
"fetchFile", new Serializable[] { file });
if (result != null) {
@SuppressWarnings("unchecked")
Map<String, Object> response = (Map<String, Object>) result;
return new String((byte[]) response.get("content"));
} else {
System.out.println("Fehler");
}
} catch (Exception e) {
// one may want to handle some exceptions differently
e.printStackTrace();
Context.get().monitorEvent(this, MonitoringEvent.SERVICE_ERROR, e.toString());
}
return "";
}
开发者ID:rwth-acis,项目名称:mobsos-success-modeling,代码行数:22,代码来源:MonitoringDataProvisionService.java
示例17: storeGraph
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Stores big graphs step by step.
*
* @param nameStr
* The name for the graph.
* @param contentStr
* The graph input.
* @return XML containing information about the stored file.
*/
@POST
@Path("storegraph")
@Produces(MediaType.TEXT_XML)
@Consumes(MediaType.TEXT_PLAIN)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 401, message = "Unauthorized") })
@ApiOperation(value = "User validation", notes = "Stores a graph step by step.")
public Response storeGraph(@DefaultValue("unnamed") @QueryParam("name") String nameStr, String contentStr) {
String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName();
File graphDir = new File("tmp" + File.separator + username);
if (!graphDir.exists()) {
graphDir.mkdirs();
}
File graphFile = new File(graphDir + File.separator + nameStr + ".txt");
try (FileWriter fileWriter = new FileWriter(graphFile, true);
BufferedWriter bufferWritter = new BufferedWriter(fileWriter);) {
if (!graphFile.exists()) {
graphFile.createNewFile();
}
bufferWritter.write(contentStr);
bufferWritter.newLine();
} catch (Exception e) {
requestHandler.log(Level.WARNING, "user: " + username, e);
return requestHandler.writeError(Error.INTERNAL, "Internal system error.");
}
return Response.ok("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + "<File>" + "<Name>" + graphFile.getName()
+ "</Name>" + "<Size>" + graphFile.length() + "</Size>" + "<Message>" + "File appned" + "</Message>"
+ "</File>").build();
}
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:39,代码来源:ServiceClass.java
示例18: processStoredGraph
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Process the stored graph which was stored by storeGraph api.
*
* @param nameStr
* The name for the stored graph.
* @param creationTypeStr
* The creation type the graph was created by.
* @param graphInputFormatStr
* The name of the graph input format.
* @param doMakeUndirectedStr
* Optional query parameter. Defines whether directed edges
* shall be turned into undirected edges (TRUE) or not.
* @param startDateStr
* Optional query parameter. For big graphs start date is the
* date from which the file will start parse.
* @param endDateStr
* Optional query parameter. For big graphs end date is the
* date till which the file will parse.
* @param indexPathStr
* Optional query parameter. Set index directory.
* @param filePathStr
* Optional query parameter. For testing purpose, file
* location of local file can be given.
* @return A graph id xml. Or an error xml.
*/
@POST
@Path("processgraph")
@Produces(MediaType.TEXT_XML)
@Consumes(MediaType.TEXT_PLAIN)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 401, message = "Unauthorized") })
@ApiOperation(value = "User validation", notes = "Process the stored graph.")
public Response processStoredGraph(@DefaultValue("unnamed") @QueryParam("name") String nameStr,
@DefaultValue("UNDEFINED") @QueryParam("creationType") String creationTypeStr,
@DefaultValue("GRAPH_ML") @QueryParam("inputFormat") String graphInputFormatStr,
@DefaultValue("FALSE") @QueryParam("doMakeUndirected") String doMakeUndirectedStr,
@DefaultValue("2004-01-01") @QueryParam("startDate") String startDateStr,
@DefaultValue("2004-01-20") @QueryParam("endDate") String endDateStr,
@DefaultValue("indexes") @QueryParam("indexPath") String indexPathStr,
@DefaultValue("ocd/test/input/stackexAcademia.xml") @QueryParam("filePath") String filePathStr) {
String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName();
File graphDir = new File("tmp" + File.separator + username);
File graphFile = new File(graphDir + File.separator + nameStr + ".txt");
StringBuffer contentStr = new StringBuffer();
if (!graphFile.exists()) {
return requestHandler.writeError(Error.INTERNAL, "Graph Does not exists.");
}
try (FileReader fileWriter = new FileReader(graphFile);
BufferedReader bufferedReader = new BufferedReader(fileWriter);) {
String line;
while ((line = bufferedReader.readLine()) != null) {
contentStr.append(line);
contentStr.append("\n");
}
} catch (Exception e) {
requestHandler.log(Level.WARNING, "user: " + username, e);
return requestHandler.writeError(Error.INTERNAL, "Internal system error.");
}
graphFile.delete();
return createGraph(nameStr, creationTypeStr, graphInputFormatStr, doMakeUndirectedStr, startDateStr,
endDateStr, indexPathStr, filePathStr, contentStr.toString());
}
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:63,代码来源:ServiceClass.java
示例19: getSimulation
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Gets the results of a performed simulation series on a network
*
* @return HttpResponse with the returnString
*/
@GET
@Path("/simulation/{seriesId}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "GET SIMULATION", notes = "Gets the results of a performed simulation")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "REPLACE THIS WITH YOUR OK MESSAGE"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized") })
public Response getSimulation(@PathParam("seriesId") long seriesId) {
String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName();
SimulationSeries series = null;
try {
series = entityHandler.getSimulationSeries(seriesId);
if (series == null)
return Response.status(Status.BAD_REQUEST).entity("no simulation with id " + seriesId + " found")
.build();
if (!series.isEvaluated()) {
series.evaluate();
}
} catch (Exception e) {
logger.log(Level.WARNING, "user: " + username, e);
e.printStackTrace();
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("internal error").build();
}
return Response.ok().entity(series).build();
}
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:37,代码来源:ServiceClass.java
示例20: getGraphById
import i5.las2peer.api.Context; //导入依赖的package包/类
/**
* Transforms the stored CustomGraph into a HashMap. The HashMap include the
* graph as adjacency list.
*
* This method is intended to be used by other las2peer services for remote
* method invocation. It returns only default types and classes.
*
*
* @param graphId
* Id of the requested stored graph
* @return HashMap
*
*/
public Map<String, Object> getGraphById(long graphId) {
String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName();
CustomGraph graph;
try {
graph = entityHandler.getGraph(username, graphId);
} catch (Exception e) {
e.printStackTrace();
return null;
}
Integer nodeCount = graph.nodeCount();
Integer edgeCount = graph.edgeCount();
Boolean directed = graph.isDirected();
Boolean weighted = graph.isWeighted();
String name = graph.getName();
InvocationHandler invocationHandler = new InvocationHandler();
List<List<Integer>> adjList = invocationHandler.getAdjList(graph);
Map<String, Object> graphData = new HashMap<String, Object>();
graphData.put("nodes", nodeCount);
graphData.put("edges", edgeCount);
graphData.put("directed", directed);
graphData.put("weighted", weighted);
graphData.put("name", name);
graphData.put("graph", adjList);
logger.log(Level.INFO, "RMI requested a graph: " + graphId);
return graphData;
}
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:45,代码来源:ServiceClass.java
注:本文中的i5.las2peer.api.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论