Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-08-26 20:31:57 +0000
committerRyan D. Brooks2011-08-26 20:31:57 +0000
commit164e440df1aebf6751f54f8f0dc7b4553aadebba (patch)
tree8f82f35439ea2c9bf5899809c35e7a3303c0eb97 /plugins/org.eclipse.osee.framework.core.dsl.ui.integration
parentf239db44fd61f0afd57944c26557642ab163abf8 (diff)
downloadorg.eclipse.osee-164e440df1aebf6751f54f8f0dc7b4553aadebba.tar.gz
org.eclipse.osee-164e440df1aebf6751f54f8f0dc7b4553aadebba.tar.xz
org.eclipse.osee-164e440df1aebf6751f54f8f0dc7b4553aadebba.zip
feature[ats_M1Y56]: Add renderer for OseeTypeDefinition artifacts
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.ui.integration')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java89
1 files changed, 87 insertions, 2 deletions
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 5214f3796de..b4d87ba3dfe 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
@@ -14,19 +14,33 @@ import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+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.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;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.types.IArtifact;
+import org.eclipse.osee.framework.ui.skynet.render.AttributeModifier;
import org.eclipse.osee.framework.ui.skynet.render.DefaultArtifactRenderer;
import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
@@ -109,9 +123,26 @@ public class OseeDslTypeSheetRenderer extends FileSystemRenderer {
@Override
public InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
+ // Pattern pattern = Pattern.compile("import\\s\"platform:/plugin/(.*)/support/(.+\\.osee)\"");
Artifact artifact = artifacts.iterator().next();
StringBuilder builder = new StringBuilder();
- builder.append(artifact.getSoleAttributeValueAsString(CoreAttributeTypes.UriGeneralStringData, ""));
+ String sheetData = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.UriGeneralStringData, "");
+ // Matcher m = pattern.matcher(sheetData);
+ // ChangeSet cs = new ChangeSet(sheetData);
+ // String fileName, packageName, change, importStatement;
+ // while (m.find()) {
+ // fileName = m.group(2);
+ // packageName = m.group(1);
+ // importStatement = m.group(0);
+ // change = "";
+ // for (String line : importStatement.split("\n")) {
+ // change += "//" + line + "\n";
+ // }
+ // change += "import \"" + OseeData.getPath() + "\\.working\\Common\\" + fileName + "\"";
+ // cs.replace(m.start(), m.end(), change);
+ // }
+
+ builder.append(sheetData);
InputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));
@@ -128,7 +159,61 @@ public class OseeDslTypeSheetRenderer extends FileSystemRenderer {
@Override
protected IOperation getUpdateOperation(File file, List<Artifact> artifacts, Branch branch, PresentationType presentationType) {
- return new WholeAttributeUpdateOperation(file, artifacts.get(0), CoreAttributeTypes.UriGeneralStringData);
+ Modifier mod = new Modifier();
+ return new WholeAttributeUpdateOperation(file, artifacts.get(0), CoreAttributeTypes.UriGeneralStringData, mod);
+ }
+
+ private class Modifier implements AttributeModifier {
+
+ @Override
+ public String modifyForSave(Artifact owner, String value) throws OseeCoreException {
+ List<Artifact> artifacts =
+ ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.OseeTypeDefinition, BranchManager.getCommonBranch());
+ StringBuilder combinedSheets = new StringBuilder();
+ for (Artifact art : artifacts) {
+ String sheetData;
+ if (art.equals(owner)) {
+ sheetData = value;
+ } else {
+ sheetData = art.getSoleAttributeValueAsString(CoreAttributeTypes.UriGeneralStringData, "");
+ }
+ combinedSheets.append(sheetData.replaceAll("import\\s+\"", "// import \""));
+ }
+ OseeDsl model = ModelUtil.loadModel("osee:/TypeModel.osee", combinedSheets.toString());
+
+ Set<Long> uuids = new HashSet<Long>();
+ EList<XArtifactType> artifactTypes = model.getArtifactTypes();
+ EList<XAttributeType> attributeTypes = model.getAttributeTypes();
+ EList<XOseeEnumType> enumTypes = model.getEnumTypes();
+ EList<XRelationType> relationTypes = model.getRelationTypes();
+
+ for (XArtifactType type : artifactTypes) {
+ addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ }
+ for (XAttributeType type : attributeTypes) {
+ addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ }
+ for (XOseeEnumType type : enumTypes) {
+ addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ }
+ for (XRelationType type : relationTypes) {
+ addUuid(OseeUtil.convertHexStringToLong(type.getUuid()), uuids);
+ }
+
+ if (uuids.contains(0L)) {
+ throw new OseeStateException("Uuid of 0 is not allowed");
+ }
+
+ return value;
+ }
+
+ private void addUuid(Long id, Set<Long> set) throws OseeStateException {
+ if (set.contains(id)) {
+ throw new OseeStateException("Duplicate uuid found: [0x%X]", id);
+ } else {
+ set.add(id);
+ }
+ }
}
}

Back to the top