|
@@ -0,0 +1,52 @@
|
|
|
+package com.persagy.ibms.data.sdk.service.rest;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.persagy.ibms.core.data.SceneDataValue;
|
|
|
+import com.persagy.ibms.core.util.ComputeUtil;
|
|
|
+import com.persagy.ibms.data.sdk.util.RepositoryContainer;
|
|
|
+import com.persagy.ibms.data.sdk.util.RepositoryImpl;
|
|
|
+
|
|
|
+public class DependencyUtil {
|
|
|
+ public static JSONObject dependency_before(JSONObject param) throws Exception {
|
|
|
+ RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
+ JSONObject result = null;
|
|
|
+ String type = (String) param.get("type");
|
|
|
+ if (type.equals("path")) {
|
|
|
+ JSONArray path = (JSONArray) param.get("path");
|
|
|
+ String[] valuePath = new String[path.size()];
|
|
|
+ for (int i = 0; i < path.size(); i++) {
|
|
|
+ valuePath[i] = path.getString(i);
|
|
|
+ }
|
|
|
+ Object valueObject = ComputeUtil.getValueObject(Repository, valuePath);
|
|
|
+ if (valueObject instanceof SceneDataValue) {
|
|
|
+ SceneDataValue sdv = (SceneDataValue) valueObject;
|
|
|
+ result = Repository.dependency.get_before(sdv);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject dependency_after(JSONObject param) throws Exception {
|
|
|
+ RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
+ JSONObject result = null;
|
|
|
+ String type = (String) param.get("type");
|
|
|
+ if (type.equals("point")) {
|
|
|
+ String point = (String) param.get("point");
|
|
|
+ SceneDataValue sdv = RepositoryContainer.RepositoryBase.point2sdv.get(point);
|
|
|
+ result = Repository.dependency.get_after(Repository, sdv);
|
|
|
+ } else if (type.equals("path")) {
|
|
|
+ JSONArray path = (JSONArray) param.get("path");
|
|
|
+ String[] valuePath = new String[path.size()];
|
|
|
+ for (int i = 0; i < path.size(); i++) {
|
|
|
+ valuePath[i] = path.getString(i);
|
|
|
+ }
|
|
|
+ Object valueObject = ComputeUtil.getValueObject(Repository, valuePath);
|
|
|
+ if (valueObject instanceof SceneDataValue) {
|
|
|
+ SceneDataValue sdv = (SceneDataValue) valueObject;
|
|
|
+ result = Repository.dependency.get_after(Repository, sdv);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|