Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-08-26 23:20:26 +0000
committerRyan D. Brooks2011-08-26 23:20:26 +0000
commit16552a4e6ecddd443f081a1726ab2b8c969aed10 (patch)
tree725c2e2484f55456719da0c95dbac193ae12d3f6 /plugins
parent164e440df1aebf6751f54f8f0dc7b4553aadebba (diff)
downloadorg.eclipse.osee-16552a4e6ecddd443f081a1726ab2b8c969aed10.tar.gz
org.eclipse.osee-16552a4e6ecddd443f081a1726ab2b8c969aed10.tar.xz
org.eclipse.osee-16552a4e6ecddd443f081a1726ab2b8c969aed10.zip
feature[ats_M1Y56]: Create HexUtil and HexUtilTest
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/DslUtilTestSuite.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtilTest.java59
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java22
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java5
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtil.java44
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java24
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java8
8 files changed, 142 insertions, 36 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/DslUtilTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/DslUtilTestSuite.java
index 62603dc5d4b..c9f65f4603d 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/DslUtilTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/DslUtilTestSuite.java
@@ -17,8 +17,10 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({ //
-ModelUtilTest.class, //
+@Suite.SuiteClasses({
+//
+ HexUtilTest.class, //
+ ModelUtilTest.class, //
OseeDslSegmentParserTest.class, //
OseeUtilTest.class, //
})
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtilTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtilTest.java
new file mode 100644
index 00000000000..82fc751e615
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtilTest.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration.util;
+
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test Case for {@link HexUtil}
+ *
+ * @author Roberto E. Escobar
+ */
+@RunWith(Parameterized.class)
+public class HexUtilTest {
+
+ private final String expectedString;
+ private final long expectedLong;
+
+ public HexUtilTest(String expectedString, long expectedLong) {
+ super();
+ this.expectedString = expectedString;
+ this.expectedLong = expectedLong;
+ }
+
+ @Test
+ public void testToLong() throws OseeCoreException {
+ long actualLong = HexUtil.toLong(expectedString);
+ Assert.assertEquals(expectedLong, actualLong);
+ }
+
+ @Test
+ public void testToString() throws OseeCoreException {
+ String actualString = HexUtil.toString(expectedLong);
+ Assert.assertEquals(expectedString, actualString);
+ }
+
+ @Parameters
+ public static List<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ {"0x1000000000000057", 1152921504606847063L},
+ {"0x2000000000000167", 2305843009213694311L},
+ {"0x3123449801273557", 3540749151688406359L},
+ {"0x00000001EDFBC123", 8287666467L}});
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
index 9a69fd0b0c6..3c50e4d9cf1 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
@@ -18,6 +18,7 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.dsl.integration.internal.Activator;
+import org.eclipse.osee.framework.core.dsl.integration.util.HexUtil;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory;
@@ -97,7 +98,8 @@ public class OseeToXtextOperation extends AbstractOperation {
model.getEnumTypes().add(modelType);
modelType.setName(enumType.getName());
- modelType.setUuid(String.valueOf(enumType.getGuid()));
+ modelType.setUuid(HexUtil.toString(enumType.getGuid()));
+ modelType.setTypeGuid(modelType.getUuid());
for (OseeEnumEntry entry : enumType.values()) {
checkForCancelledStatus(monitor);
@@ -122,7 +124,10 @@ public class OseeToXtextOperation extends AbstractOperation {
model.getAttributeTypes().add(modelType);
modelType.setName(attributeType.getName());
- modelType.setUuid(String.valueOf(attributeType.getGuid()));
+
+ modelType.setUuid(HexUtil.toString(attributeType.getGuid()));
+ modelType.setTypeGuid(modelType.getUuid());
+
modelType.setBaseAttributeType(asPrimitiveType(attributeType.getBaseAttributeTypeId()));
modelType.setDataProvider(asPrimitiveType(attributeType.getAttributeProviderId()));
modelType.setMax(String.valueOf(attributeType.getMaxOccurrences()));
@@ -152,8 +157,8 @@ public class OseeToXtextOperation extends AbstractOperation {
model.getArtifactTypes().add(modelType);
modelType.setName(artifactType.getName());
- modelType.setUuid(String.valueOf(artifactType.getGuid()));
-
+ modelType.setUuid(HexUtil.toString(artifactType.getGuid()));
+ modelType.setTypeGuid(modelType.getUuid());
}
monitor.worked(calculateWork(workPercentage));
}
@@ -223,7 +228,8 @@ public class OseeToXtextOperation extends AbstractOperation {
model.getRelationTypes().add(modelType);
modelType.setName(relationType.getName());
- modelType.setUuid(String.valueOf(relationType.getGuid()));
+ modelType.setUuid(HexUtil.toString(relationType.getGuid()));
+ modelType.setTypeGuid(modelType.getUuid());
modelType.setDefaultOrderType(OseeUtil.getRelationOrderType(relationType.getDefaultOrderTypeGuid()));
modelType.setMultiplicity(RelationMultiplicityEnum.getByName(relationType.getMultiplicity().name()));
@@ -239,7 +245,7 @@ public class OseeToXtextOperation extends AbstractOperation {
private XArtifactType getArtifactType(OseeDsl model, Long guid) throws OseeCoreException {
for (XArtifactType type : model.getArtifactTypes()) {
- Long normalizedGuid = OseeUtil.convertHexStringToLong(type.getUuid());
+ Long normalizedGuid = HexUtil.toLong(type.getUuid());
if (guid.equals(normalizedGuid)) {
return type;
}
@@ -249,7 +255,7 @@ public class OseeToXtextOperation extends AbstractOperation {
private XAttributeType getAttributeType(OseeDsl model, Long guid) throws OseeCoreException {
for (XAttributeType type : model.getAttributeTypes()) {
- Long normalizedGuid = OseeUtil.convertHexStringToLong(type.getUuid());
+ Long normalizedGuid = HexUtil.toLong(type.getUuid());
if (guid.equals(normalizedGuid)) {
return type;
}
@@ -260,7 +266,7 @@ public class OseeToXtextOperation extends AbstractOperation {
private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) throws OseeCoreException {
Long guid = oseeEnumType.getGuid();
for (XOseeEnumType type : model.getEnumTypes()) {
- Long normalizedGuid = OseeUtil.convertHexStringToLong(type.getUuid());
+ Long normalizedGuid = HexUtil.toLong(type.getUuid());
if (guid.equals(normalizedGuid)) {
return type;
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
index c1599cb7392..5647c1f288d 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.BranchToken;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.dsl.integration.internal.Activator;
+import org.eclipse.osee.framework.core.dsl.integration.util.HexUtil;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.AddEnum;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
@@ -185,7 +186,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
OseeEnumType oseeEnumType =
provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(),
- OseeUtil.convertHexStringToLong(xEnumType.getUuid()), enumTypeName);
+ HexUtil.toLong(xEnumType.getUuid()), enumTypeName);
int lastOrdinal = 0;
List<OseeEnumEntry> oseeEnumEntries = new ArrayList<OseeEnumEntry>();
@@ -289,7 +290,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
}
private long convertHexToLong(String hexString) throws OseeCoreException {
- return OseeUtil.convertHexStringToLong(hexString);
+ return HexUtil.toLong(hexString);
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtil.java
new file mode 100644
index 00000000000..c6c058111db
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/HexUtil.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration.util;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class HexUtil {
+
+ private HexUtil() {
+ // Utility class
+ }
+
+ public static long toLong(String hexString) throws OseeCoreException {
+ Long toReturn = -1L;
+ try {
+ String hex = hexString;
+ if (hexString.startsWith("0x")) {
+ hex = hexString.substring(2);
+ }
+ toReturn = Long.parseLong(hex, 16);
+ } catch (Exception ex) {
+ throw new OseeCoreException(String.format("Error converting [%s] to java.util.Long", hexString), ex);
+ }
+ return toReturn;
+
+ }
+
+ public static String toString(long value) throws OseeCoreException {
+ // String hexString = Long.toHexString(value).toUpperCase();
+ return String.format("0x%016X", value);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java
index 03557420b07..18d07a32fb6 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java
@@ -37,15 +37,18 @@ public final class OseeUtil {
}
public static IArtifactType toToken(XArtifactType model) throws OseeCoreException {
- return TokenFactory.createArtifactType(convertHexStringToLong(model.getUuid()), Strings.unquote(model.getName()));
+ return TokenFactory.createArtifactType(HexUtil.toLong(model.getUuid()),
+ Strings.unquote(model.getName()));
}
public static IAttributeType toToken(XAttributeType model) throws OseeCoreException {
- return TokenFactory.createAttributeType(convertHexStringToLong(model.getUuid()), Strings.unquote(model.getName()));
+ return TokenFactory.createAttributeType(HexUtil.toLong(model.getUuid()),
+ Strings.unquote(model.getName()));
}
public static IRelationType toToken(XRelationType model) throws OseeCoreException {
- return TokenFactory.createRelationType(convertHexStringToLong(model.getUuid()), Strings.unquote(model.getName()));
+ return TokenFactory.createRelationType(HexUtil.toLong(model.getUuid()),
+ Strings.unquote(model.getName()));
}
public static boolean isRestrictedSide(XRelationSideEnum relationSideEnum, RelationSide relationSide) throws OseeCoreException {
@@ -91,19 +94,4 @@ public final class OseeUtil {
Conditions.checkNotNull(orderTypeName, "orderTypeName");
return RelationOrderBaseTypes.getFromOrderTypeName(orderTypeName.replaceAll("_", " ")).getGuid();
}
-
- public static long convertHexStringToLong(String hexString) throws OseeCoreException {
- Long toReturn = -1L;
- try {
- String hex = hexString;
- if (hexString.startsWith("0x")) {
- hex = hexString.substring(2);
- }
- toReturn = Long.parseLong(hex, 16);
- } catch (Exception ex) {
- throw new OseeCoreException(String.format("Error converting [%s] to java.util.Long", hexString), ex);
- }
- return toReturn;
-
- }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java
index b4d87ba3dfe..d4e2b396d5e 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java
@@ -20,8 +20,8 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.osee.framework.core.dsl.integration.util.HexUtil;
import org.eclipse.osee.framework.core.dsl.integration.util.ModelUtil;
-import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
@@ -188,16 +188,16 @@ public class OseeDslTypeSheetRenderer extends FileSystemRenderer {
EList<XRelationType> relationTypes = model.getRelationTypes();
for (XArtifactType type : artifactTypes) {
- addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ addUuid(HexUtil.toLong(type.getUuid()), uuids);
}
for (XAttributeType type : attributeTypes) {
- addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ addUuid(HexUtil.toLong(type.getUuid()), uuids);
}
for (XOseeEnumType type : enumTypes) {
- addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ addUuid(HexUtil.toLong(type.getUuid()), uuids);
}
for (XRelationType type : relationTypes) {
- addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ addUuid(HexUtil.toLong(type.getUuid()), uuids);
}
if (uuids.contains(0L)) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java
index afee879ebe5..f8562cefefa 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java
@@ -90,6 +90,9 @@ public class ClientArtifactTypeAccessor extends AbstractClientDataAccessor<Long,
for (Triplet<Long, String, Long> entry : response.getAttributeTypes()) {
ArtifactType key1 = cache.getByGuid(entry.getFirst());
+ if (key1 == null) {
+ System.out.printf("Null ArtType [%s]\n", entry.getFirst());
+ }
IOseeBranch key2 = branchCache.getByGuid(entry.getSecond());
Collection<AttributeType> types = attrs.get(key1, key2);
if (types == null) {
@@ -100,7 +103,10 @@ public class ClientArtifactTypeAccessor extends AbstractClientDataAccessor<Long,
}
for (Entry<Pair<ArtifactType, IOseeBranch>, Collection<AttributeType>> entry : attrs.entrySet()) {
- entry.getKey().getFirst().setAttributeTypes(entry.getValue(), entry.getKey().getSecond());
+ ArtifactType type = entry.getKey().getFirst();
+ IOseeBranch branch = entry.getKey().getSecond();
+ Collection<AttributeType> attrTypes = entry.getValue();
+ type.setAttributeTypes(attrTypes, branch);
}
return updatedItems;
}

Back to the top