diff options
author | jmisinco | 2011-08-16 15:59:49 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-08-16 15:59:49 +0000 |
commit | 63984fcdeff57c500df0c9ce52114f3f6670eb0d (patch) | |
tree | 5e0d3f68bd511a01b9c05d441e624e2e1c2327ad /plugins/org.eclipse.osee.framework.core.dsl.integration | |
parent | 612e819915757a6d9f13a32afd924ba497517bb9 (diff) | |
download | org.eclipse.osee-63984fcdeff57c500df0c9ce52114f3f6670eb0d.tar.gz org.eclipse.osee-63984fcdeff57c500df0c9ce52114f3f6670eb0d.tar.xz org.eclipse.osee-63984fcdeff57c500df0c9ce52114f3f6670eb0d.zip |
feature[ats_M1Y56]: Add uuid to Osee type grammar
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.integration')
7 files changed, 74 insertions, 39 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF index a6012628809..7345d4a4318 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF @@ -22,6 +22,8 @@ Import-Package: org.eclipse.core.runtime, org.eclipse.osee.framework.core.operation, org.eclipse.osee.framework.core.services, org.eclipse.osee.framework.core.util, + org.eclipse.osee.framework.database, + org.eclipse.osee.framework.database.core, org.eclipse.osee.framework.jdk.core.text.change, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java index ac56fa8d742..5c9f4b9c866 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java @@ -53,7 +53,7 @@ public class CreateOseeTypeChangesReportOperation extends AbstractOperation { columns.add("Name"); columns.add("StorageState"); if (!types.isEmpty()) { - AbstractOseeType type = (AbstractOseeType) types.iterator().next(); + AbstractOseeType<?> type = (AbstractOseeType<?>) types.iterator().next(); columns.addAll(type.getFieldNames()); } return columns.toArray(new String[columns.size()]); 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 0a0b4dfda7b..9a69fd0b0c6 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 @@ -97,7 +97,7 @@ public class OseeToXtextOperation extends AbstractOperation { model.getEnumTypes().add(modelType); modelType.setName(enumType.getName()); - modelType.setTypeGuid(enumType.getGuid()); + modelType.setUuid(String.valueOf(enumType.getGuid())); for (OseeEnumEntry entry : enumType.values()) { checkForCancelledStatus(monitor); @@ -122,7 +122,7 @@ public class OseeToXtextOperation extends AbstractOperation { model.getAttributeTypes().add(modelType); modelType.setName(attributeType.getName()); - modelType.setTypeGuid(attributeType.getGuid()); + modelType.setUuid(String.valueOf(attributeType.getGuid())); modelType.setBaseAttributeType(asPrimitiveType(attributeType.getBaseAttributeTypeId())); modelType.setDataProvider(asPrimitiveType(attributeType.getAttributeProviderId())); modelType.setMax(String.valueOf(attributeType.getMaxOccurrences())); @@ -152,7 +152,7 @@ public class OseeToXtextOperation extends AbstractOperation { model.getArtifactTypes().add(modelType); modelType.setName(artifactType.getName()); - modelType.setTypeGuid(artifactType.getGuid()); + modelType.setUuid(String.valueOf(artifactType.getGuid())); } monitor.worked(calculateWork(workPercentage)); @@ -223,7 +223,7 @@ public class OseeToXtextOperation extends AbstractOperation { model.getRelationTypes().add(modelType); modelType.setName(relationType.getName()); - modelType.setTypeGuid(relationType.getGuid()); + modelType.setUuid(String.valueOf(relationType.getGuid())); modelType.setDefaultOrderType(OseeUtil.getRelationOrderType(relationType.getDefaultOrderTypeGuid())); modelType.setMultiplicity(RelationMultiplicityEnum.getByName(relationType.getMultiplicity().name())); @@ -237,9 +237,9 @@ public class OseeToXtextOperation extends AbstractOperation { monitor.worked(calculateWork(workPercentage)); } - private XArtifactType getArtifactType(OseeDsl model, String guid) { + private XArtifactType getArtifactType(OseeDsl model, Long guid) throws OseeCoreException { for (XArtifactType type : model.getArtifactTypes()) { - String normalizedGuid = type.getTypeGuid(); + Long normalizedGuid = OseeUtil.convertHexStringToLong(type.getUuid()); if (guid.equals(normalizedGuid)) { return type; } @@ -247,9 +247,9 @@ public class OseeToXtextOperation extends AbstractOperation { return null; } - private XAttributeType getAttributeType(OseeDsl model, String guid) { + private XAttributeType getAttributeType(OseeDsl model, Long guid) throws OseeCoreException { for (XAttributeType type : model.getAttributeTypes()) { - String normalizedGuid = type.getTypeGuid(); + Long normalizedGuid = OseeUtil.convertHexStringToLong(type.getUuid()); if (guid.equals(normalizedGuid)) { return type; } @@ -257,10 +257,10 @@ public class OseeToXtextOperation extends AbstractOperation { return null; } - private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) { - String guid = oseeEnumType.getGuid(); + private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) throws OseeCoreException { + Long guid = oseeEnumType.getGuid(); for (XOseeEnumType type : model.getEnumTypes()) { - String normalizedGuid = type.getTypeGuid(); + Long normalizedGuid = OseeUtil.convertHexStringToLong(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 4585cd0f089..c1599cb7392 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 @@ -47,6 +47,7 @@ import org.eclipse.osee.framework.core.model.type.OseeEnumType; import org.eclipse.osee.framework.core.model.type.RelationType; import org.eclipse.osee.framework.core.operation.AbstractOperation; import org.eclipse.osee.framework.core.services.IOseeModelFactoryService; +import org.eclipse.osee.framework.database.core.RemoteIdManager; import org.eclipse.osee.framework.jdk.core.util.Strings; /** @@ -58,9 +59,11 @@ public class XTextToOseeTypeOperation extends AbstractOperation { private final OseeDsl model; private final OseeTypeCache typeCache; private final BranchCache branchCache; + private final RemoteIdManager idManager; - public XTextToOseeTypeOperation(IOseeModelFactoryService provider, OseeTypeCache typeCache, BranchCache branchCache, OseeDsl model) { + public XTextToOseeTypeOperation(RemoteIdManager idManager, IOseeModelFactoryService provider, OseeTypeCache typeCache, BranchCache branchCache, OseeDsl model) { super("OSEE Text Model to OSEE", Activator.PLUGIN_ID); + this.idManager = idManager; this.provider = provider; this.typeCache = typeCache; this.branchCache = branchCache; @@ -113,7 +116,8 @@ public class XTextToOseeTypeOperation extends AbstractOperation { } private void handleXArtifactTypeCrossRef(XArtifactType xArtifactType) throws OseeCoreException { - ArtifactType targetArtifactType = typeCache.getArtifactTypeCache().getByGuid(xArtifactType.getTypeGuid()); + ArtifactType targetArtifactType = + typeCache.getArtifactTypeCache().getByGuid(convertHexToLong(xArtifactType.getUuid())); translateSuperTypes(targetArtifactType, xArtifactType); Map<IOseeBranch, Collection<AttributeType>> validAttributesPerBranch = getOseeAttributes(xArtifactType); targetArtifactType.setAllAttributeTypes(validAttributesPerBranch); @@ -138,7 +142,8 @@ public class XTextToOseeTypeOperation extends AbstractOperation { for (XAttributeTypeRef xAttributeTypeRef : xArtifactType.getValidAttributeTypes()) { XAttributeType xAttributeType = xAttributeTypeRef.getValidAttributeType(); IOseeBranch branch = getAttributeBranch(xAttributeTypeRef); - AttributeType oseeAttributeType = typeCache.getAttributeTypeCache().getByGuid(xAttributeType.getTypeGuid()); + AttributeType oseeAttributeType = + typeCache.getAttributeTypeCache().getByGuid(convertHexToLong(xAttributeType.getUuid())); if (oseeAttributeType != null) { Collection<AttributeType> listOfAllowedAttributes = validAttributes.get(branch); if (listOfAllowedAttributes == null) { @@ -169,18 +174,18 @@ public class XTextToOseeTypeOperation extends AbstractOperation { private void translateXArtifactType(XArtifactType xArtifactType) throws OseeCoreException { String artifactTypeName = xArtifactType.getName(); - ArtifactType oseeArtifactType = - provider.getArtifactTypeFactory().createOrUpdate(typeCache.getArtifactTypeCache(), - xArtifactType.getTypeGuid(), xArtifactType.isAbstract(), artifactTypeName); - xArtifactType.setTypeGuid(oseeArtifactType.getGuid()); + // ArtifactType oseeArtifactType = + provider.getArtifactTypeFactory().createOrUpdate(typeCache.getArtifactTypeCache(), + convertHexToLong(xArtifactType.getUuid()), xArtifactType.isAbstract(), artifactTypeName); + // xArtifactType.setUuid(String.valueOf(oseeArtifactType.getGuid())); } private void translateXEnumType(XOseeEnumType xEnumType) throws OseeCoreException { String enumTypeName = xEnumType.getName(); OseeEnumType oseeEnumType = - provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(), xEnumType.getTypeGuid(), - enumTypeName); + provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(), + OseeUtil.convertHexStringToLong(xEnumType.getUuid()), enumTypeName); int lastOrdinal = 0; List<OseeEnumEntry> oseeEnumEntries = new ArrayList<OseeEnumEntry>(); @@ -230,12 +235,12 @@ public class XTextToOseeTypeOperation extends AbstractOperation { XOseeEnumType xEnumType = xAttributeType.getEnumType(); OseeEnumType oseeEnumType = null; if (xEnumType != null) { - oseeEnumType = typeCache.getEnumTypeCache().getByGuid(xEnumType.getTypeGuid()); + oseeEnumType = typeCache.getEnumTypeCache().getByGuid(convertHexToLong(xEnumType.getUuid())); } AttributeTypeCache cache = typeCache.getAttributeTypeCache(); AttributeType oseeAttributeType = provider.getAttributeTypeFactory().createOrUpdate(cache, // - xAttributeType.getTypeGuid(), // + convertHexToLong(xAttributeType.getUuid()), // xAttributeType.getName(), // getQualifiedTypeName(xAttributeType.getBaseAttributeType()), // getQualifiedTypeName(xAttributeType.getDataProvider()), // @@ -247,7 +252,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation { xAttributeType.getDescription(), // xAttributeType.getTaggerId()// ); - xAttributeType.setTypeGuid(oseeAttributeType.getGuid()); + // xAttributeType.setUuid(String.valueOf(oseeAttributeType.getGuid())); } private String getQualifiedTypeName(String id) { @@ -270,7 +275,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation { RelationType oseeRelationType = provider.getRelationTypeFactory().createOrUpdate(typeCache.getRelationTypeCache(), // - xRelationType.getTypeGuid(), // + convertHexToLong(xRelationType.getUuid()), // xRelationType.getName(), // xRelationType.getSideAName(), // xRelationType.getSideBName(), // @@ -280,7 +285,11 @@ public class XTextToOseeTypeOperation extends AbstractOperation { OseeUtil.orderTypeNameToGuid(xRelationType.getDefaultOrderType()) // ); - xRelationType.setTypeGuid(oseeRelationType.getGuid()); + // xRelationType.setUuid(String.valueOf(oseeRelationType.getGuid())); + } + + private long convertHexToLong(String hexString) throws OseeCoreException { + return OseeUtil.convertHexStringToLong(hexString); } } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java index 922e2b9e6a5..a4ae6a15621 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java @@ -38,6 +38,7 @@ import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory; import org.eclipse.osee.framework.core.services.IOseeModelFactoryService; +import org.eclipse.osee.framework.database.IOseeDatabaseService; import org.eclipse.osee.framework.jdk.core.util.Lib; /** @@ -49,13 +50,14 @@ public class OseeModelingServiceImpl implements IOseeModelingService { private final IOseeCachingService systemCachingService; private final IOseeCachingServiceFactory cachingFactoryService; private final OseeDslFactory modelFactory; + private final IOseeDatabaseService dbService; - public OseeModelingServiceImpl(IOseeModelFactoryService modelFactoryService, IOseeCachingService systemCachingService, IOseeCachingServiceFactory cachingFactoryService, OseeDslFactory dslFactory) { + public OseeModelingServiceImpl(IOseeDatabaseService dbService, IOseeModelFactoryService modelFactoryService, IOseeCachingService systemCachingService, IOseeCachingServiceFactory cachingFactoryService, OseeDslFactory dslFactory) { + this.dbService = dbService; this.modelFactoryService = modelFactoryService; this.systemCachingService = systemCachingService; this.cachingFactoryService = cachingFactoryService; this.modelFactory = dslFactory; - } @Override @@ -99,8 +101,8 @@ public class OseeModelingServiceImpl implements IOseeModelingService { ops.add(new OseeToXtextOperation(tempCache, modelFactory, baseModel)); } - ops.add(new XTextToOseeTypeOperation(modelFactoryService, tempCache, tempCacheService.getBranchCache(), - inputModel)); + ops.add(new XTextToOseeTypeOperation(dbService.getRemoteIdManager(), modelFactoryService, tempCache, + tempCacheService.getBranchCache(), inputModel)); if (request.isCreateTypeChangeReport()) { ops.add(new CreateOseeTypeChangesReportOperation(tempCache, reportData)); } @@ -118,6 +120,11 @@ public class OseeModelingServiceImpl implements IOseeModelingService { if (isInitializing) { systemCachingService.clearAll(); } + systemCachingService.getEnumTypeCache().cacheFrom(tempCache.getEnumTypeCache()); + systemCachingService.getAttributeTypeCache().cacheFrom(tempCache.getAttributeTypeCache()); + systemCachingService.getArtifactTypeCache().cacheFrom(tempCache.getArtifactTypeCache()); + systemCachingService.getRelationTypeCache().cacheFrom(tempCache.getRelationTypeCache()); + systemCachingService.reloadAll(); } else { response.setPersisted(false); @@ -132,6 +139,7 @@ public class OseeModelingServiceImpl implements IOseeModelingService { response.setComparisonSnapshotModel(modelString); } } + // Map<String, OseeTypeModel> changedModels = new HashMap<String, OseeTypeModel>(); // doSubWork(new OseeToXtextOperation(modifiedCache, changedModels), monitor, 0.20); // diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java index 73bbd73ed4a..55847cab428 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java @@ -17,6 +17,7 @@ import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory; import org.eclipse.osee.framework.core.services.IOseeModelFactoryService; import org.eclipse.osee.framework.core.util.AbstractTrackingHandler; +import org.eclipse.osee.framework.database.IOseeDatabaseService; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -25,8 +26,7 @@ import org.osgi.framework.ServiceRegistration; */ public class OseeModelingServiceRegHandler extends AbstractTrackingHandler { - private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] { - // + private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {IOseeDatabaseService.class,// IOseeCachingService.class, // IOseeModelFactoryService.class, // IOseeCachingServiceFactory.class // @@ -44,9 +44,10 @@ public class OseeModelingServiceRegHandler extends AbstractTrackingHandler { IOseeModelFactoryService modelFactoryService = getService(IOseeModelFactoryService.class, services); IOseeCachingService cachingService = getService(IOseeCachingService.class, services); IOseeCachingServiceFactory cachingFactoryService = getService(IOseeCachingServiceFactory.class, services); + IOseeDatabaseService dbService = getService(IOseeDatabaseService.class, services); IOseeModelingService service = - new OseeModelingServiceImpl(modelFactoryService, cachingService, cachingFactoryService, + new OseeModelingServiceImpl(dbService, modelFactoryService, cachingService, cachingFactoryService, OseeDslFactory.eINSTANCE); registration = context.registerService(IOseeModelingService.class.getName(), service, null); } 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 c53c05d2609..03557420b07 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 @@ -36,16 +36,16 @@ public final class OseeUtil { // Utility Class } - public static IArtifactType toToken(XArtifactType model) { - return TokenFactory.createArtifactType(Strings.unquote(model.getTypeGuid()), Strings.unquote(model.getName())); + public static IArtifactType toToken(XArtifactType model) throws OseeCoreException { + return TokenFactory.createArtifactType(convertHexStringToLong(model.getUuid()), Strings.unquote(model.getName())); } - public static IAttributeType toToken(XAttributeType model) { - return TokenFactory.createAttributeType(Strings.unquote(model.getTypeGuid()), Strings.unquote(model.getName())); + public static IAttributeType toToken(XAttributeType model) throws OseeCoreException { + return TokenFactory.createAttributeType(convertHexStringToLong(model.getUuid()), Strings.unquote(model.getName())); } - public static IRelationType toToken(XRelationType model) { - return TokenFactory.createRelationType(Strings.unquote(model.getTypeGuid()), Strings.unquote(model.getName())); + public static IRelationType toToken(XRelationType model) throws OseeCoreException { + return TokenFactory.createRelationType(convertHexStringToLong(model.getUuid()), Strings.unquote(model.getName())); } public static boolean isRestrictedSide(XRelationSideEnum relationSideEnum, RelationSide relationSide) throws OseeCoreException { @@ -91,4 +91,19 @@ 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; + + } } |