Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-11 21:39:37 -0400
committerrescobar2010-08-11 21:39:37 -0400
commit3984975c1c79b16f772d48456f330cbbc7befc6b (patch)
treee861841015f98568f70b768abaf305694efe82c5 /plugins/org.eclipse.osee.framework.core.dsl.ui.integration
parent9ea7683683c4c569b2ea104653565d3be765f61c (diff)
downloadorg.eclipse.osee-3984975c1c79b16f772d48456f330cbbc7befc6b.tar.gz
org.eclipse.osee-3984975c1c79b16f772d48456f330cbbc7befc6b.tar.xz
org.eclipse.osee-3984975c1c79b16f772d48456f330cbbc7befc6b.zip
"Team Workflow" - YGHW1 - "Block changes to requirements unless done under an appropriate action."
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.ui.integration')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslArtifactUpdateOperation.java62
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java11
3 files changed, 58 insertions, 17 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF
index 87a1573bc66..9cd9290ea13 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF
@@ -31,6 +31,7 @@ Import-Package: org.eclipse.compare,
org.eclipse.osee.framework.core.translation,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.database.init,
+ org.eclipse.osee.framework.jdk.core.text.change,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.framework.jdk.core.util.xml,
@@ -41,6 +42,7 @@ Import-Package: org.eclipse.compare,
org.eclipse.osee.framework.skynet.core.artifact.search,
org.eclipse.osee.framework.skynet.core.attribute,
org.eclipse.osee.framework.skynet.core.importing,
+ org.eclipse.osee.framework.skynet.core.transaction,
org.eclipse.osee.framework.skynet.core.utility,
org.eclipse.osee.framework.ui.plugin,
org.eclipse.osee.framework.ui.plugin.util,
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslArtifactUpdateOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslArtifactUpdateOperation.java
index b152be3503a..d694e4d7a86 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslArtifactUpdateOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslArtifactUpdateOperation.java
@@ -11,17 +11,23 @@
package org.eclipse.osee.framework.core.dsl.ui.integration.internal;
import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
+import org.eclipse.osee.framework.core.dsl.integration.util.OseeDslSegmentParser;
+import org.eclipse.osee.framework.core.dsl.integration.util.OseeDslSegmentParser.OseeDslSegment;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.Lib;
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.transaction.SkynetTransaction;
/**
* @author Roberto E. Escobar
@@ -29,25 +35,55 @@ import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
public class OseeDslArtifactUpdateOperation extends AbstractOperation {
private final File file;
+ private final OseeDslSegmentParser parser;
- public OseeDslArtifactUpdateOperation(File file) {
+ public OseeDslArtifactUpdateOperation(OseeDslSegmentParser parser, File file) {
super("OseeDsl Artifact Update", Activator.PLUGIN_ID);
this.file = file;
+ this.parser = parser;
}
@Override
protected void doWork(IProgressMonitor monitor) throws Exception {
- String source = Lib.fileToString(file);
- Pair<String, String> metaData = OseeUtil.fromOseeDslArtifactSource(source);
- Conditions.checkNotNull(metaData, "artifact source", "Unable to find artifact source marker for file [%s]",
- file.getAbsolutePath());
+ String source = getSource();
+ Collection<OseeDslSegment> segments = parser.getSegments(source);
+ if (segments.isEmpty()) {
+ throw new OseeStateException("No tagged segments Found");
+ } else {
+ double workPercentage = 0.80 * (1.0 / segments.size());
+ int workAmount = calculateWork(workPercentage);
- String branchGuid = metaData.getFirst();
- String artifactGuid = metaData.getSecond();
+ Map<Branch, SkynetTransaction> transactionMap = new HashMap<Branch, SkynetTransaction>();
+ for (OseeDslSegment segment : segments) {
+ int startAt = segment.end();
+ int endAt = segment.start();
+
+ String data = source.substring(startAt, endAt);
+ addChanges(transactionMap, segment.getBranchGuid(), segment.getArtifactGuid(), data);
+ monitor.worked(workAmount);
+ }
+ monitor.setTaskName("Persist...");
+ for (SkynetTransaction transaction : transactionMap.values()) {
+ transaction.execute();
+ }
+ monitor.worked(calculateWork(0.20));
+ }
+ }
+
+ protected String getSource() throws IOException {
+ return Lib.fileToString(file);
+ }
+
+ protected void addChanges(Map<Branch, SkynetTransaction> transactionMap, String branchGuid, String artifactGuid, String data) throws OseeCoreException {
Branch branch = BranchManager.getBranchByGuid(branchGuid);
+ SkynetTransaction transaction = transactionMap.get(branch);
+ if (transaction == null) {
+ transaction = new SkynetTransaction(branch, "OseeDslArtifactUpdate");
+ transactionMap.put(branch, transaction);
+ }
Artifact artifact = ArtifactQuery.getArtifactFromId(artifactGuid, branch);
-
- artifact.setSoleAttributeFromString(CoreAttributeTypes.GeneralStringData, source);
- artifact.persist();
+ artifact.setSoleAttributeFromString(CoreAttributeTypes.GeneralStringData, data);
+ artifact.persist(transaction);
}
+
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
index 5b8d4b884ea..c63cb31649d 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
@@ -18,7 +18,7 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
-import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
+import org.eclipse.osee.framework.core.dsl.integration.util.OseeDslSegmentParser;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -47,12 +47,13 @@ public final class OseeDslRenderer extends FileSystemRenderer {
private static final String COMMAND_ID = "org.eclipse.osee.framework.core.dsl.OseeDsl.editor.command";
+ private static final OseeDslSegmentParser parser = new OseeDslSegmentParser();
private static final class OseeDslArtifactUpdateOperationFactory implements IArtifactUpdateOperationFactory {
@SuppressWarnings("unused")
@Override
public IOperation createUpdateOp(File file) throws OseeCoreException {
- return new OseeDslArtifactUpdateOperation(file);
+ return new OseeDslArtifactUpdateOperation(parser, file);
}
};
@@ -74,7 +75,7 @@ public final class OseeDslRenderer extends FileSystemRenderer {
public int getApplicabilityRating(PresentationType presentationType, Artifact artifact) {
if (presentationType != GENERALIZED_EDIT && !artifact.isHistorical()) {
if (artifact.isOfType(CoreArtifactTypes.AccessControlModel)) {
- return SUBTYPE_TYPE_MATCH;
+ return ARTIFACT_TYPE_MATCH;
}
}
return NO_MATCH;
@@ -133,9 +134,11 @@ public final class OseeDslRenderer extends FileSystemRenderer {
public InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
Artifact artifact = artifacts.iterator().next();
StringBuilder builder = new StringBuilder();
- builder.append(OseeUtil.getOseeDslArtifactSource(artifact));
+ builder.append(parser.getStartTag(artifact));
builder.append("\n");
builder.append(artifact.getSoleAttributeValueAsString(CoreAttributeTypes.GeneralStringData, ""));
+ builder.append("\n");
+ builder.append(parser.getEndTag(artifact));
InputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));

Back to the top