Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.rest')
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/config.css12
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/main.html92
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/orcsConfig.js59
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TypesEndpointImpl.java134
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/PredicateHandlerUtil.java3
7 files changed, 296 insertions, 10 deletions
diff --git a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
index b9f1a3ab08..827dc79119 100644
--- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 0.25.0.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Service-Component: OSGI-INF/*.xml
+Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.base;version="15.0.0",
com.google.common.collect;version="15.0.0",
com.google.common.net,
@@ -50,4 +51,5 @@ Import-Package: com.google.common.base;version="15.0.0",
org.osgi.service.event;version="1.3.1"
Osee-JaxRs-Resource: OSEE-INF/web/script/*;path=/orcs/script/ui,
OSEE-INF/web/example/*;path=/orcs/example/ui,
- OSEE-INF/web/writer/*;path=/orcs/writer/ui
+ OSEE-INF/web/writer/*;path=/orcs/writer/ui,
+ OSEE-INF/web/config/*;path=/orcs/types/config/ui
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/config.css b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/config.css
new file mode 100644
index 0000000000..76560ef829
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/config.css
@@ -0,0 +1,12 @@
+.drop-box {
+ background: #F8F8F8;
+ border: 5px dashed #DDD;
+ width: 200px;
+ height: 65px;
+ text-align: center;
+ padding-top: 25px;
+ margin: 10px;
+}
+.dragover {
+ border: 5px dashed blue;
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/main.html b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/main.html
new file mode 100644
index 0000000000..b006851bd7
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/main.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta charset="UTF-8"></meta>
+<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
+<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
+
+<link rel="stylesheet" type="text/css"
+ href="/ajax/libs/bootstrap/3.3.2/css/bootstrap.min.css"></link>
+<link rel="stylesheet" type="text/css" href="config.css"></link>
+
+<title>OSEE - ORCS Config</title>
+<script src="/ajax/libs/angularjs/1.2.28/angular.min.js"></script>
+<script src="/ajax/libs/angularjs/1.2.28/angular-resource.min.js"></script>
+<script
+ src="http://vitalets.github.io/checklist-model/checklist-model.js"></script>
+<script src="orcsConfig.js"></script>
+<script type="text/ng-template" id="loadingModal.html">
+ <div id="loadingModal" class="alert alert-info">Loading...</div></script>
+
+</head>
+
+<body>
+ <div ng-app="app" class="row" ng-controller="appCtrl">
+
+
+ <nav class="navbar navbar-default" role="navigation">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle" data-toggle="collapse"
+ data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span> <span
+ class="icon-bar"></span> <span class="icon-bar"></span> <span
+ class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="../ui/main.html">OSEE - ORCS
+ Configuration</a>
+ </div>
+ <div class="collapse navbar-collapse" ng-controller="appCtrl">
+ <ul class="nav navbar-nav navbar-right">
+ <li ng-class="home"><a href="../ui/main.html">Home</a></li>
+ </ul>
+ </div>
+ </div>
+ </nav>
+
+ <div class="container">
+ <p>
+ <b> ORCS Config provides the ability to set the OSEE Types
+ version and sheets.<br />
+ <ul>
+ <li>Select code version</li>
+ <li>Select OSEE Types Artifacts</li>
+ <li>Click Execute</li>
+ </ul>
+ </b>
+ </p>
+ </div>
+
+ <div class="container">
+ <label>Input: </label><br /> <br />
+ <div class="form-group">
+ <label>Version: </label>
+ <textarea class="form-control" rows="1"
+ placeholder="code version number" ng-model="formData.version"
+ title="Version"></textarea>
+ <br />
+
+ <div class="col-xs-24 col-sm-12">
+ <label>OSEE Type Artifacts: </label> <label
+ ng-repeat="sheet in sheets"> <input type="checkbox"
+ checklist-model="formData.sheets" checklist-value="sheet.attrId">
+ {{sheet.name}}
+ </label>
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+ <div class="form-group">
+ <button type="submit" class="btn btn-primary" ng-click="run()">Execute</button>
+ </div>
+
+ <div class="container-fluid well" ng-show="message">
+ <textarea rows="30" class="form-control">{{ message }}</textarea>
+ </div>
+
+ </div>
+ </div>
+</body>
+</html>
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/orcsConfig.js b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/orcsConfig.js
new file mode 100644
index 0000000000..2e95ffd342
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/config/orcsConfig.js
@@ -0,0 +1,59 @@
+var app = angular.module('app', [ 'checklist-model', 'ngResource' ]);
+
+app.controller("appCtrl", [
+ '$scope',
+ '$http',
+ '$resource',
+ function($scope, $http, $resource) {
+
+ $scope.formData = {
+ version : '',
+ sheets : ''
+ };
+ $scope.message = '';
+
+ $scope.execute = function() {
+ $scope.run();
+ }
+
+ $scope.loadSheets = function() {
+ $http.get('/orcs/types/config/sheet').then(function(response) {
+ $scope.sheets = response.data;
+ });
+ }
+
+ $scope.run = function() {
+ $scope.message = '';
+ var url = "/orcs/types/config/sheet";
+ var data = {};
+ if (!$scope.formData.version
+ && !$scope.formData.sheets.length > 0) {
+ $scope.message = "ERROR: Must enter version and sheets";
+ } else {
+ $scope.message = "Processing...";
+ data.versionNum = $scope.formData.version;
+ data.sheets = [];
+ var x = 0;
+ for (x = 0; x < $scope.formData.sheets.length; x++) {
+ data.sheets[x] = {};
+ data.sheets[x].attrId = $scope.formData.sheets[x];
+ }
+ $http({
+ method : 'POST',
+ url : url,
+ data : data,
+ headers : {
+ 'Accept' : 'application/json',
+ 'Content-Type' : 'application/json'
+ }
+ }).success(function(data, status, headers, config) {
+ $scope.message += '\n\nCompleted';
+ }).error(function(data, status, headers, config) {
+ $scope.message += '\n\n' + data.message;
+ });
+ }
+ }
+
+ $scope.loadSheets();
+
+ } ]);
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
index 710cc2852e..f48fecb1d9 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
@@ -75,7 +75,7 @@ public class OrcsApplication extends Application {
resources.add(new BranchEndpointImpl(orcsApi, resourceManager, activityLog));
resources.add(new OrcsWriterEndpointImpl(orcsApi));
resources.add(new TransactionEndpointImpl(orcsApi));
- resources.add(new TypesEndpointImpl(orcsApi, eventAdmin));
+ resources.add(new TypesEndpointImpl(orcsApi, eventAdmin, jdbcService));
resources.add(new IndexerEndpointImpl(orcsApi));
resources.add(new ResourcesEndpointImpl(resourceManager));
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TypesEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TypesEndpointImpl.java
index ba992d2f47..eb5cdac7f7 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TypesEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TypesEndpointImpl.java
@@ -19,6 +19,8 @@ import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -27,23 +29,33 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.AttributeId;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.OrcsTypeSheet;
+import org.eclipse.osee.framework.core.data.OrcsTypesConfig;
import org.eclipse.osee.framework.core.data.OrcsTypesData;
+import org.eclipse.osee.framework.core.data.OrcsTypesSheet;
+import org.eclipse.osee.framework.core.data.OrcsTypesVersion;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreTupleTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.framework.jdk.core.util.HexUtil;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.jaxrs.OseeWebApplicationException;
+import org.eclipse.osee.jdbc.JdbcService;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.OrcsTypes;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.AttributeTypes;
import org.eclipse.osee.orcs.data.EnumEntry;
import org.eclipse.osee.orcs.data.EnumType;
@@ -62,10 +74,12 @@ public class TypesEndpointImpl implements TypesEndpoint {
private final OrcsApi orcsApi;
private final EventAdmin eventAdmin;
+ private final JdbcService jdbcService;
- public TypesEndpointImpl(OrcsApi orcsApi, EventAdmin eventAdmin) {
+ public TypesEndpointImpl(OrcsApi orcsApi, EventAdmin eventAdmin, JdbcService jdbcService) {
this.orcsApi = orcsApi;
this.eventAdmin = eventAdmin;
+ this.jdbcService = jdbcService;
}
private OrcsTypes getOrcsTypes() {
@@ -180,12 +194,10 @@ public class TypesEndpointImpl implements TypesEndpoint {
for (EnumEntry enumEntry : enumType.values()) {
JaxEnumEntry entry = new JaxEnumEntry();
entry.setName(enumEntry.getName());
- Long uuid = null;
String guid = enumEntry.getGuid();
+ Long uuid = null;
if (Strings.isNumeric(guid)) {
uuid = Long.valueOf(guid);
- } else if (HexUtil.isHexString(guid)) {
- uuid = HexUtil.toLong(guid);
}
if (uuid != null) {
entry.setUuid(uuid);
@@ -246,4 +258,116 @@ public class TypesEndpointImpl implements TypesEndpoint {
return Response.ok().entity("Success").build();
}
+ public static final String LOAD_OSEE_TYPE_DEF_NAME_AND_ID =
+ "select attr.value, attr.art_id, attr.attr_id, attr.attr_type_id from osee_attribute attr, osee_txs txs where txs.BRANCH_ID = ? " + //
+ "and attr.gamma_id = txs.gamma_id and txs.TX_CURRENT = 1 and attr.art_id " + //
+ "in (select distinct art_id from osee_attribute where attr_id in (ATTR_IDS)) order by attr_type_id desc";
+
+ @Override
+ public Response getConfig() {
+
+ OrcsTypesConfig config = new OrcsTypesConfig();
+ config.setCurrentVersion(OrcsTypesData.OSEE_TYPE_VERSION.intValue());
+ List<Integer> attrIds = new LinkedList<>();
+
+ jdbcService.getClient().runQuery(stmt1 -> {
+ int version = stmt1.getInt("e1");
+ final OrcsTypesVersion typeVersion = new OrcsTypesVersion();
+ config.getVersions().add(typeVersion);
+ typeVersion.setVersionNum(version);
+
+ jdbcService.getClient().runQuery(stmt2 -> {
+ OrcsTypesSheet sheet = new OrcsTypesSheet();
+ sheet.setAttrId(stmt2.getInt("attr_id"));
+ attrIds.add(new Long(sheet.getAttrId()).intValue());
+ typeVersion.getSheets().add(sheet);
+ }, OrcsTypes.LOAD_OSEE_TYPE_DEF_URIS, CoreTupleTypes.OseeTypeDef, CoreBranches.COMMON,
+ TxChange.CURRENT.getValue(), typeVersion.getVersionNum(), TxChange.CURRENT.getValue());
+
+ }, OrcsTypes.LOAD_OSEE_TYPE_VERSIONS, CoreTupleTypes.OseeTypeDef.getId());
+
+ String query = LOAD_OSEE_TYPE_DEF_NAME_AND_ID.replace("ATTR_IDS", Collections.toString(",", attrIds));
+ jdbcService.getClient().runQuery(stmt -> {
+ long attrId = stmt.getLong("attr_id");
+ long attrTypeId = stmt.getLong("attr_type_id");
+ long artId = stmt.getLong("art_id");
+ if (CoreAttributeTypes.UriGeneralStringData.getId().equals(attrTypeId)) {
+ for (OrcsTypesSheet sheet : getSheetsFromAttrId(attrId, config)) {
+ sheet.setArtifactId(artId);
+ }
+ } else if (CoreAttributeTypes.Name.getId().equals(attrTypeId)) {
+ for (OrcsTypesSheet sheet : getSheetsFromArtId(artId, config)) {
+ sheet.setName(stmt.getString("value"));
+ }
+ }
+ }, query, CoreBranches.COMMON.getId());
+ return Response.ok(config).build();
+ }
+
+ private Collection<OrcsTypesSheet> getSheetsFromArtId(Long artId, OrcsTypesConfig config) {
+ List<OrcsTypesSheet> sheets = new LinkedList<>();
+ for (OrcsTypesVersion version : config.getVersions()) {
+ for (OrcsTypesSheet sheet : version.getSheets()) {
+ if (artId.equals(sheet.getArtifactId())) {
+ sheets.add(sheet);
+ }
+ }
+ }
+ return sheets;
+ }
+
+ private Collection<OrcsTypesSheet> getSheetsFromAttrId(Long attrId, OrcsTypesConfig config) {
+ List<OrcsTypesSheet> sheets = new LinkedList<>();
+ for (OrcsTypesVersion version : config.getVersions()) {
+ for (OrcsTypesSheet sheet : version.getSheets()) {
+ if (attrId.equals(sheet.getAttrId())) {
+ sheets.add(sheet);
+ }
+ }
+ }
+ return sheets;
+ }
+
+ @Override
+ public Response getConfigSheets() {
+ List<OrcsTypesSheet> sheets = new LinkedList<>();
+ for (ArtifactReadable art : orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andIsOfType(
+ CoreArtifactTypes.OseeTypeDefinition, CoreArtifactTypes.OseeTypeDefinitionTemp).getResults()) {
+ OrcsTypesSheet sheet = new OrcsTypesSheet();
+ sheet.setArtifactId(art.getId());
+ sheet.setName(art.getName());
+ ResultSet<? extends AttributeReadable<Object>> attributes =
+ art.getAttributes(CoreAttributeTypes.UriGeneralStringData);
+ if (!attributes.isEmpty()) {
+ sheet.setAttrId(attributes.iterator().next().getId());
+ }
+ sheets.add(sheet);
+ }
+ return Response.ok(sheets).build();
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public Response setConfigSheets(OrcsTypesVersion version) {
+ // clear out existing config, if any
+ TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(COMMON, SystemUser.OseeSystem,
+ "Set OSEE Types Configuration");
+ long verNum = version.getVersionNum();
+
+ Iterable<Long> attrIds = orcsApi.getQueryFactory().tupleQuery().getTuple2Raw(CoreTupleTypes.OseeTypeDef, COMMON,
+ Long.valueOf(version.getVersionNum()));
+ for (Long attrId : attrIds) {
+ throw new OseeStateException("Configuration already exist for version %s; these need to be manually removed",
+ version);
+ }
+
+ // add type configuration
+ for (OrcsTypesSheet sheet : version.getSheets()) {
+ tx.addTuple2(CoreTupleTypes.OseeTypeDef, verNum, AttributeId.valueOf(sheet.getAttrId()));
+ }
+
+ tx.commit();
+ return Response.ok(version).build();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/PredicateHandlerUtil.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/PredicateHandlerUtil.java
index fb628c2a29..1c976ad886 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/PredicateHandlerUtil.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/PredicateHandlerUtil.java
@@ -19,7 +19,6 @@ import org.eclipse.osee.framework.core.data.RelationTypeSide;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.HexUtil;
/**
* @author John R. Misinco
@@ -80,8 +79,6 @@ public class PredicateHandlerUtil {
private static long parseUuid(String uuid) throws OseeCoreException {
if (uuid.matches("-?\\d+")) {
return Long.parseLong(uuid);
- } else if (HexUtil.isHexString(uuid)) {
- return HexUtil.toLong(uuid);
}
return -1L;
}

Back to the top