Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2021-01-04 15:14:14 +0000
committerDonald Dunne2021-01-05 17:18:42 +0000
commit917c3b624038c5bb3101c4c388bec8c7bee51fae (patch)
treed47772664d48b4f978b600ebd269f18aaeef9f07
parent93673a6127e3b086ce860cb303110cbfb9f5c987 (diff)
downloadorg.eclipse.osee-917c3b624038c5bb3101c4c388bec8c7bee51fae.tar.gz
org.eclipse.osee-917c3b624038c5bb3101c4c388bec8c7bee51fae.tar.xz
org.eclipse.osee-917c3b624038c5bb3101c4c388bec8c7bee51fae.zip
bug[TW18549]: Improve Validate Type to find prod attrs with no code ref
-rw-r--r--plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ValidateOseeTypes.java29
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TypesEndpoint.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/types/HealthReportOperation.java79
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/types/TypesEndpointImpl.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TypesEndpointImpl.java)9
6 files changed, 104 insertions, 22 deletions
diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ValidateOseeTypes.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ValidateOseeTypes.java
index 66634058949..a90c0bf94b6 100644
--- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ValidateOseeTypes.java
+++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ValidateOseeTypes.java
@@ -13,14 +13,10 @@
package org.eclipse.osee.ats.ide.navigate;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.osee.ats.ide.AtsImage;
-import org.eclipse.osee.ats.ide.internal.AtsApiService;
-import org.eclipse.osee.framework.core.data.ArtifactTypeToken;
-import org.eclipse.osee.framework.core.data.AttributeTypeGeneric;
-import org.eclipse.osee.framework.core.data.AttributeTypeToken;
+import org.eclipse.osee.ats.ide.util.ServiceUtil;
import org.eclipse.osee.framework.jdk.core.result.XResultData;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
@@ -37,23 +33,14 @@ public class ValidateOseeTypes extends XNavigateItemAction {
@Override
public void run(TableLoadOption... tableLoadOptions) throws Exception {
- XResultData rd = new XResultData();
-
- List<AttributeTypeGeneric<?>> attrTypes = new ArrayList<>();
- attrTypes.addAll(AtsApiService.get().tokenService().getAttributeTypes());
-
- for (ArtifactTypeToken artType : AtsApiService.get().tokenService().getArtifactTypes()) {
- for (AttributeTypeToken attrType : artType.getValidAttributeTypes()) {
- attrTypes.remove(attrType);
- }
- }
- rd.log(getName() + "\n");
- rd.log("Attribute Types without Artifact reference: " + "\n");
- for (AttributeTypeToken attrType : attrTypes) {
- rd.log(attrType.toStringWithId());
+ XResultData rd = new XResultData();
+ try {
+ rd = ServiceUtil.getOseeClient().getTypesEndpoint().getHealthReport();
+ } catch (Exception ex) {
+ rd.errorf(getName() + " Exception %s", Lib.exceptionToString(ex));
}
-
XResultDataUI.report(rd, getName());
+
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java
index 2537c9a78d8..5ddbe80d9d6 100644
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java
+++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/ApplicationServerManager.java
@@ -21,6 +21,7 @@ import java.net.UnknownHostException;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
+import org.eclipse.osee.framework.core.data.OseeClient;
import org.eclipse.osee.framework.core.data.OseeCodeVersion;
import org.eclipse.osee.framework.core.data.OseeServerInfo;
import org.eclipse.osee.framework.core.operation.Operations;
@@ -60,6 +61,7 @@ public class ApplicationServerManager implements IApplicationServerManager {
dataStore = new ApplicationServerDataStore(jdbcService.getClient());
serverInfo = createOseeServerInfo(getLogger(), dataStore, OseeCodeVersion.getVersion());
System.setProperty("OseeApplicationServer", serverInfo.getUri().toString());
+ System.setProperty(OseeClient.OSEE_APPLICATION_SERVER, serverInfo.getUri().toString());
timer = new Timer();
timer.schedule(new TimerTask() {
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TypesEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TypesEndpoint.java
index d51fe4dd2e3..f1cdc252129 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TypesEndpoint.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TypesEndpoint.java
@@ -21,6 +21,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.core.data.OrcsTypesVersion;
+import org.eclipse.osee.framework.jdk.core.result.XResultData;
/**
* @author Roberto E. Escobar
@@ -48,4 +49,9 @@ public interface TypesEndpoint {
@Produces({MediaType.APPLICATION_JSON})
Response setConfigSheets(OrcsTypesVersion version);
+ @GET
+ @Path("health")
+ @Produces({MediaType.APPLICATION_JSON})
+ XResultData getHealthReport();
+
} \ No newline at end of file
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 46944136ff1..a74eec31798 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
@@ -23,6 +23,7 @@ import org.eclipse.osee.jdbc.JdbcService;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.rest.admin.LinkUpdateResource;
import org.eclipse.osee.orcs.rest.internal.applicability.ApplicabilityUiEndpointImpl;
+import org.eclipse.osee.orcs.rest.internal.types.TypesEndpointImpl;
import org.eclipse.osee.orcs.rest.internal.writer.OrcsWriterEndpointImpl;
import org.osgi.service.event.EventAdmin;
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/types/HealthReportOperation.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/types/HealthReportOperation.java
new file mode 100644
index 00000000000..3f880b09d6f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/types/HealthReportOperation.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Boeing.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.internal.types;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.OrcsTokenService;
+import org.eclipse.osee.framework.core.data.ArtifactTypeToken;
+import org.eclipse.osee.framework.core.data.AttributeTypeGeneric;
+import org.eclipse.osee.framework.core.data.AttributeTypeToken;
+import org.eclipse.osee.framework.core.data.OseeClient;
+import org.eclipse.osee.framework.jdk.core.result.XResultData;
+import org.eclipse.osee.jdbc.JdbcService;
+import org.eclipse.osee.jdbc.JdbcStatement;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class HealthReportOperation {
+
+ private final OrcsTokenService tokenService;
+ private final JdbcService jdbcService;
+
+ public HealthReportOperation(OrcsTokenService tokenService, JdbcService jdbcService) {
+ this.tokenService = tokenService;
+ this.jdbcService = jdbcService;
+ }
+
+ public XResultData run() {
+ XResultData rd = new XResultData();
+
+ List<AttributeTypeGeneric<?>> attrTypes = new ArrayList<>();
+ attrTypes.addAll(tokenService.getAttributeTypes());
+
+ for (ArtifactTypeToken artType : tokenService.getArtifactTypes()) {
+ for (AttributeTypeToken attrType : artType.getValidAttributeTypes()) {
+ attrTypes.remove(attrType);
+ }
+ }
+
+ rd.log("ORCS Types Health Check\n");
+ rd.log("Server: " + OseeClient.getOseeApplicationServer() + "\n");
+ rd.log("Attribute Types defined in code without Artifact reference in code: \n");
+ for (AttributeTypeToken attrType : attrTypes) {
+ if (attrType.isValid()) {
+ rd.error(attrType.toStringWithId());
+ }
+ }
+
+ rd.log("\nAttribute Types used in database and not defined in code: \n");
+
+ JdbcStatement chStmt = jdbcService.getClient().getStatement();
+ try {
+ String query = "SELECT UNIQUE attr_type_id FROM osee_attribute";
+ chStmt.runPreparedQuery(query);
+ while (chStmt.next()) {
+ Long attrTypeId = chStmt.getLong("attr_type_id");
+ AttributeTypeGeneric<?> attributeType = tokenService.getAttributeTypeOrSentinel(attrTypeId);
+ if (attributeType.isInvalid()) {
+ rd.error(attrTypeId.toString());
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+
+ return rd;
+ }
+}
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/types/TypesEndpointImpl.java
index 975608758a7..89af0415038 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/types/TypesEndpointImpl.java
@@ -11,7 +11,7 @@
* Boeing - initial API and implementation
**********************************************************************/
-package org.eclipse.osee.orcs.rest.internal;
+package org.eclipse.osee.orcs.rest.internal.types;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.executeCallable;
@@ -34,6 +34,7 @@ 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.TxCurrent;
+import org.eclipse.osee.framework.jdk.core.result.XResultData;
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;
@@ -77,6 +78,12 @@ public class TypesEndpointImpl implements TypesEndpoint {
"in (select distinct art_id from osee_attribute where attr_id in (ATTR_IDS)) order by attr_type_id desc";
@Override
+ public XResultData getHealthReport() {
+ HealthReportOperation reportOp = new HealthReportOperation(orcsApi.tokenService(), jdbcService);
+ return reportOp.run();
+ }
+
+ @Override
public Response getConfig() {
OrcsTypesConfig config = new OrcsTypesConfig();

Back to the top