diff options
Diffstat (limited to 'plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client')
16 files changed, 818 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoArtifactTypes.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoArtifactTypes.java new file mode 100644 index 00000000000..81030115a05 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoArtifactTypes.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo; + +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.data.TokenFactory; + +/** + * @author Roberto E. Escobar + */ +public final class DemoArtifactTypes { + + // @formatter:off + public static final IArtifactType DemoTestRequirement = TokenFactory.createArtifactType(0x0000000000000056L, "Demo Artifact With Selective Partition"); + // @formatter:on + + private DemoArtifactTypes() { + // Constants + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoBranches.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoBranches.java new file mode 100644 index 00000000000..bee9adbcd03 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoBranches.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.client.demo; + +import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.data.TokenFactory; + +/** + * @author Donald G. Dunne + */ +public final class DemoBranches { + + public static final IOseeBranch SAW_Bld_1 = TokenFactory.createBranch("AyH_f2sSKy3l07fIvAAA", "SAW_Bld_1"); + public static final IOseeBranch SAW_Bld_2 = TokenFactory.createBranch("AyH_f2sSKy3l07fIvBBB", "SAW_Bld_2"); + public static final IOseeBranch SAW_Bld_3 = TokenFactory.createBranch("AyH_f2sSKy3l07fIvCCC", "SAW_Bld_3"); + + public static final IOseeBranch CIS_Bld_1 = TokenFactory.createBranch("AyH_f2sSKy3l07fIvDDD", "CIS_Bld_1"); + public static final IOseeBranch CIS_Bld_2 = TokenFactory.createBranch("AyH_f2sSKy3l07fIvEEE", "CIS_Bld_2"); + public static final IOseeBranch CIS_Bld_3 = TokenFactory.createBranch("AyH_f2sSKy3l07fIvFFF", "CIS_Bld_3"); + + private DemoBranches() { + // Constants + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoChoice.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoChoice.java new file mode 100644 index 00000000000..36bb6d1e53d --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoChoice.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo; + +import org.eclipse.osee.framework.database.init.IDbInitChoiceEnum; + +/** + * @author Roberto E. Escobar + */ +public enum DemoChoice implements IDbInitChoiceEnum { + + OSEE_CLIENT_DEMO; + +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoCscis.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoCscis.java new file mode 100644 index 00000000000..f28a5533e79 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoCscis.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * 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.client.demo; + +/** + * @author Donald G. Dunne + */ +public enum DemoCscis { + CoreUnit, + Framework, + Interface, + Navigation, + Unspecified, + Visual; +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoSubsystems.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoSubsystems.java new file mode 100644 index 00000000000..2aa147da8c4 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoSubsystems.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.client.demo; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * @author Donald G. Dunne + */ +public enum DemoSubsystems { + Robot_API, + Robot_Survivability_Equipment, + Robot_Systems_Management, + Chasis, + Cognitive_Decision_Aiding, + Communications, + Data_Management, + Electrical, + Controls, + Hydraulics, + Navigation, + Propulsion, + Unknown, + Unspecified; + + public static String[] getSubsystemArray() { + return getSubsystems().toArray(new String[getSubsystems().size()]); + } + + public static Collection<String> getSubsystems() { + ArrayList<String> subsystems = new ArrayList<String>(); + for (DemoSubsystems subsystem : DemoSubsystems.values()) { + subsystems.add(subsystem.name()); + } + return subsystems; + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoTraceability.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoTraceability.java new file mode 100644 index 00000000000..33ac844c099 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoTraceability.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo; + +/** + * @author Roberto E. Escobar + */ +public final class DemoTraceability { + + public static final String DEMO_TRACE_UNIT_HANDLER_ID = "org.eclipse.osee.client.demo.DemoTraceUnitHandler"; + + private DemoTraceability() { + // Constants class + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoUsers.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoUsers.java new file mode 100644 index 00000000000..a0b084dbb8f --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/DemoUsers.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2011 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.client.demo; + +import java.util.Arrays; +import java.util.List; +import org.eclipse.osee.framework.core.data.IUserToken; +import org.eclipse.osee.framework.core.data.TokenFactory; + +/** + * @author Donald G. Dunne + */ +public final class DemoUsers { + + // @formatter:off + public static final IUserToken Joe_Smith = TokenFactory.createUserToken("ABNRvbZxXHICYklfslwA", "Joe Smith", "", "Joe Smith", false, false, false); + public static final IUserToken Kay_Jones = TokenFactory.createUserToken("ABNRvuB8x3VARkkn3YAA", "Kay Jones", "", "Kay Jones", false, false, false); + public static final IUserToken Jason_Michael = TokenFactory.createUserToken("ABNRvuHWtXAdxbG3mUAA", "Jason Michael", "", "Jason Michael", true, false, false); + public static final IUserToken Alex_Kay = TokenFactory.createUserToken("ABNRvuKDIWOcPDe4X0wA", "Alex Kay", "", "Alex Kay", true, false, false); + public static final IUserToken Inactive_Steve = TokenFactory.createUserToken("ABNRvuRG6jKwKnEoX4gA", "Inactive Steve", "", "Inactive Steve", false, false, false); + public static List<IUserToken> values = Arrays.asList(Joe_Smith, Kay_Jones, Jason_Michael, Alex_Kay, Inactive_Steve); + // @formatter:on + + private DemoUsers() { + // Constants + } + + public static List<IUserToken> values() { + return values; + } + +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AbstractAddRequirementsBranch.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AbstractAddRequirementsBranch.java new file mode 100644 index 00000000000..7011db304f7 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AbstractAddRequirementsBranch.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo.internal; + +import org.eclipse.osee.client.demo.DemoSubsystems; +import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.database.init.IDbInitializationTask; +import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; +import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; +import org.eclipse.osee.framework.skynet.core.utility.Requirements; + +/** + * @author Roberto E. Escobar + */ +public abstract class AbstractAddRequirementsBranch implements IDbInitializationTask { + + private final IOseeBranch branch; + + protected AbstractAddRequirementsBranch(IOseeBranch branch) { + this.branch = branch; + } + + @Override + public void run() throws OseeCoreException { + Branch requirementsBranch = BranchManager.createTopLevelBranch(branch); + + Artifact sawProduct = + ArtifactTypeManager.addArtifact(CoreArtifactTypes.Component, requirementsBranch, "SAW Product Decomposition"); + + for (String subsystem : DemoSubsystems.getSubsystems()) { + sawProduct.addChild(ArtifactTypeManager.addArtifact(CoreArtifactTypes.Component, requirementsBranch, subsystem)); + } + + Artifact programRoot = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(requirementsBranch); + programRoot.addChild(sawProduct); + + for (String name : new String[] { + Requirements.SYSTEM_REQUIREMENTS, + Requirements.SUBSYSTEM_REQUIREMENTS, + Requirements.SOFTWARE_REQUIREMENTS, + Requirements.HARDWARE_REQUIREMENTS, + "Verification Tests", + "Validation Tests", + "Integration Tests"}) { + programRoot.addChild(ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, requirementsBranch, name)); + } + + sawProduct.persist(getClass().getSimpleName()); + programRoot.persist(getClass().getSimpleName()); + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddCisBranch.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddCisBranch.java new file mode 100644 index 00000000000..4bef8e2ffa6 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddCisBranch.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * 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.client.demo.internal; + +import org.eclipse.osee.client.demo.DemoBranches; + +/** + * @author Roberto E. Escobar + */ +public class AddCisBranch extends AbstractAddRequirementsBranch { + + public AddCisBranch() { + super(DemoBranches.CIS_Bld_1); + } + +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java new file mode 100644 index 00000000000..7fb3cb2897c --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo.internal; + +import org.eclipse.osee.client.demo.DemoChoice; +import org.eclipse.osee.framework.database.init.DatabaseInitConfiguration; +import org.eclipse.osee.framework.database.init.DefaultDbInitTasks; +import org.eclipse.osee.framework.database.init.DefaultOseeTypeDefinitions; +import org.eclipse.osee.framework.database.init.IAddDbInitChoice; +import org.eclipse.osee.framework.database.init.IGroupSelector; + +/** + * @author Roberto E. Escobar + */ +public class AddClientDemoInitConfig implements IAddDbInitChoice { + + @Override + public void addDbInitChoice(IGroupSelector groupSelection) { + DatabaseInitConfiguration config = new DatabaseInitConfiguration(); + config.addTask(asLocalExtensionId("AddCommonBranchForClientDemo")); + config.addTask("org.eclipse.osee.framework.access.provider.FrameworkAccessConfig"); + + config.addTask(asLocalExtensionId("AddDemoUsers")); + config.addTask(DefaultDbInitTasks.SIMPLE_TEMPLATE_PROVIDER.getExtensionId()); + config.addTask(asLocalExtensionId("AddSawBranch")); + config.addTask(asLocalExtensionId("AddCisBranch")); + config.addTask(asLocalExtensionId("AddRequirementData")); + + config.addOseeType(DefaultOseeTypeDefinitions.OSEE_BASE_TYPES); + config.addOseeType(DefaultOseeTypeDefinitions.DEFINE_TYPES); + config.addOseeType(asLocalExtensionId("OseeTypes_ClientDemo")); + + groupSelection.addChoice(DemoChoice.OSEE_CLIENT_DEMO.name(), config); + } + + private String asLocalExtensionId(String contributionId) { + return String.format("org.eclipse.osee.client.demo.%s", contributionId); + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddCommonBranchForClientDemo.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddCommonBranchForClientDemo.java new file mode 100644 index 00000000000..6d3685da0ae --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddCommonBranchForClientDemo.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo.internal; + +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.database.init.AddCommonBranch; + +/** + * @author Roberto E. Escobar + */ +public class AddCommonBranchForClientDemo extends AddCommonBranch { + + @Override + public void run() throws OseeCoreException { + super.run(); + // Customized here; + } + +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddDemoUsers.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddDemoUsers.java new file mode 100644 index 00000000000..5bd4deb4f78 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddDemoUsers.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo.internal; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.osee.client.demo.DemoUsers; +import org.eclipse.osee.framework.core.data.IUserToken; +import org.eclipse.osee.framework.core.enums.CoreBranches; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.database.init.IDbInitializationTask; +import org.eclipse.osee.framework.skynet.core.SystemGroup; +import org.eclipse.osee.framework.skynet.core.User; +import org.eclipse.osee.framework.skynet.core.UserManager; +import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; +import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; + +/** + * @author Roberto E. Escobar + */ +public class AddDemoUsers implements IDbInitializationTask { + + @Override + public void run() throws OseeCoreException { + List<User> admins = new ArrayList<User>(); + + SkynetTransaction transaction = TransactionManager.createTransaction(CoreBranches.COMMON, "Add Dev Users"); + for (IUserToken userEnum : DemoUsers.values()) { + User user = UserManager.createUser(userEnum, transaction); + if (userEnum.isAdmin()) { + admins.add(user); + } + } + + transaction.execute(); + + SkynetTransaction transaction1 = TransactionManager.createTransaction(CoreBranches.COMMON, "Configure OSEEAdmin"); + SystemGroup.OseeAdmin.getArtifact().persist(transaction1); + transaction1.execute(); + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java new file mode 100644 index 00000000000..4f506d86368 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java @@ -0,0 +1,262 @@ +/******************************************************************************* + * 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.client.demo.internal; + +import static java.lang.Thread.sleep; +import java.io.File; +import java.net.URL; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.osee.client.demo.DemoBranches; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.data.IRelationTypeSide; +import org.eclipse.osee.framework.core.enums.BranchType; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeExceptions; +import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.core.operation.IOperation; +import org.eclipse.osee.framework.core.operation.Operations; +import org.eclipse.osee.framework.database.core.ConnectionHandler; +import org.eclipse.osee.framework.database.init.IDbInitializationTask; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; +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.importing.parsers.IArtifactExtractor; +import org.eclipse.osee.framework.skynet.core.importing.parsers.WordOutlineExtractor; +import org.eclipse.osee.framework.skynet.core.importing.parsers.WordOutlineExtractorDelegate; +import org.eclipse.osee.framework.skynet.core.importing.resolvers.IArtifactImportResolver; +import org.eclipse.osee.framework.skynet.core.importing.resolvers.NewArtifactImportResolver; +import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; +import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; +import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportOperationFactory; +import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportOperationParameter; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * @author Donald G. Dunne + */ +public class AddRequirementData implements IDbInitializationTask { + + private static boolean DEBUG = false; + private static final String UPDATE_BRANCH_TYPE = "update osee_branch set branch_type = ? where branch_id = ?"; + + @Override + public void run() throws OseeCoreException { + try { + // Import all requirements on SAW_Bld_1 Branch + IOseeBranch branch = DemoBranches.SAW_Bld_1; + + importRequirements(branch, CoreArtifactTypes.SoftwareRequirement, "support/SAW-SoftwareRequirements.xml"); + importRequirements(branch, CoreArtifactTypes.SystemRequirement, "support/SAW-SystemRequirements.xml"); + importRequirements(branch, CoreArtifactTypes.SubsystemRequirement, "support/SAW-SubsystemRequirements.xml"); + + SkynetTransaction demoDbTraceability = + TransactionManager.createTransaction(branch, "Populate Demo DB - Create Traceability"); + demoDbTraceabilityTx(demoDbTraceability, branch); + demoDbTraceability.execute(); + + // Create SAW_Bld_2 Child Main Working Branch off SAW_Bld_1 + if (DEBUG) { + OseeLog.log(AddRequirementData.class, Level.INFO, "Creating SAW_Bld_2 branch off SAW_Bld_1"); + } + // Create SAW_Bld_2 branch off SAW_Bld_1 + Branch childBranch = BranchManager.createBaselineBranch(DemoBranches.SAW_Bld_1, DemoBranches.SAW_Bld_2); + + sleep(5000); + // need to update the branch type; + ConnectionHandler.runPreparedUpdate(UPDATE_BRANCH_TYPE, new Object[] { + BranchType.BASELINE.getValue(), + childBranch.getId()}); + BranchManager.refreshBranches(); + } catch (Exception ex) { + OseeExceptions.wrapAndThrow(ex); + } + } + + private String toPlural(String value) { + return String.format("%ss", value); + } + + private void importRequirements(IOseeBranch branch, IArtifactType requirementType, String filename) throws Exception { + String rootArtifactName = toPlural(requirementType.getName()); + if (DEBUG) { + OseeLog.logf(AddRequirementData.class, Level.INFO, "Importing \"%s\" requirements on branch \"%s\"", + rootArtifactName, branch); + } + Artifact systemReq = ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, rootArtifactName, branch); + + IArtifactImportResolver artifactResolver = + new NewArtifactImportResolver(requirementType, CoreArtifactTypes.Heading); + IArtifactExtractor extractor = new WordOutlineExtractor(); + extractor.setDelegate(new WordOutlineExtractorDelegate()); + + ArtifactImportOperationParameter importOptions = new ArtifactImportOperationParameter(); + importOptions.setSourceFile(getResourceFile(filename)); + importOptions.setDestinationArtifact(systemReq); + importOptions.setExtractor(extractor); + importOptions.setResolver(artifactResolver); + + IOperation operation = ArtifactImportOperationFactory.completeOperation(importOptions); + Operations.executeWorkAndCheckStatus(operation); + + // Validate that something was imported + if (systemReq.getChildren().isEmpty()) { + throw new IllegalStateException("Artifacts were not imported"); + } + } + + private File getResourceFile(String resource) throws Exception { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + URL url = bundle.getResource(resource); + url = FileLocator.toFileURL(url); + File file = new File(url.toURI()); + return file; + } + + private void relate(IRelationTypeSide relationSide, Artifact artifact, Collection<Artifact> artifacts) throws OseeCoreException { + for (Artifact otherArtifact : artifacts) { + artifact.addRelation(relationSide, otherArtifact); + } + } + + private void demoDbTraceabilityTx(SkynetTransaction transaction, IOseeBranch branch) throws Exception { + Collection<Artifact> systemArts = + getArtTypeRequirements(DEBUG, CoreArtifactTypes.SystemRequirement, "Robot", branch); + + Collection<Artifact> component = getArtTypeRequirements(DEBUG, CoreArtifactTypes.Component, "API", branch); + component.addAll(getArtTypeRequirements(DEBUG, CoreArtifactTypes.Component, "Hardware", branch)); + component.addAll(getArtTypeRequirements(DEBUG, CoreArtifactTypes.Component, "Sensor", branch)); + + Collection<Artifact> subSystemArts = + getArtTypeRequirements(DEBUG, CoreArtifactTypes.SubsystemRequirement, "Robot", branch); + subSystemArts.addAll(getArtTypeRequirements(DEBUG, CoreArtifactTypes.SubsystemRequirement, "Video", branch)); + subSystemArts.addAll(getArtTypeRequirements(DEBUG, CoreArtifactTypes.SubsystemRequirement, "Interface", branch)); + + Collection<Artifact> softArts = + getArtTypeRequirements(DEBUG, CoreArtifactTypes.SoftwareRequirement, "Robot", branch); + softArts.addAll(getArtTypeRequirements(DEBUG, CoreArtifactTypes.SoftwareRequirement, "Interface", branch)); + + // Relate System to SubSystem to Software Requirements + for (Artifact systemArt : systemArts) { + relate(CoreRelationTypes.Requirement_Trace__Lower_Level, systemArt, subSystemArts); + systemArt.persist(transaction); + + for (Artifact subSystemArt : subSystemArts) { + relate(CoreRelationTypes.Requirement_Trace__Lower_Level, subSystemArt, softArts); + subSystemArt.persist(transaction); + } + } + + // Relate System, SubSystem and Software Requirements to Componets + for (Artifact art : systemArts) { + relate(CoreRelationTypes.Allocation__Component, art, component); + art.persist(transaction); + } + for (Artifact art : subSystemArts) { + relate(CoreRelationTypes.Allocation__Component, art, component); + art.persist(transaction); + } + for (Artifact art : softArts) { + relate(CoreRelationTypes.Allocation__Component, art, component); + } + + // Create Test Script Artifacts + Set<Artifact> verificationTests = new HashSet<Artifact>(); + Artifact verificationHeader = + ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, "Verification Tests", branch); + if (verificationHeader == null) { + throw new IllegalStateException("Could not find Verification Tests header"); + } + for (String str : new String[] {"A", "B", "C"}) { + Artifact newArt = + ArtifactTypeManager.addArtifact(CoreArtifactTypes.TestCase, verificationHeader.getBranch(), + "Verification Test " + str); + verificationTests.add(newArt); + verificationHeader.addRelation(CoreRelationTypes.Default_Hierarchical__Child, newArt); + newArt.persist(transaction); + } + Artifact verificationTestsArray[] = verificationTests.toArray(new Artifact[verificationTests.size()]); + + // Create Validation Test Procedure Artifacts + Set<Artifact> validationTests = new HashSet<Artifact>(); + Artifact validationHeader = + ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, "Validation Tests", branch); + if (validationHeader == null) { + throw new IllegalStateException("Could not find Validation Tests header"); + } + for (String str : new String[] {"1", "2", "3"}) { + Artifact newArt = + ArtifactTypeManager.addArtifact(CoreArtifactTypes.TestProcedure, validationHeader.getBranch(), + "Validation Test " + str); + validationTests.add(newArt); + validationHeader.addRelation(CoreRelationTypes.Default_Hierarchical__Child, newArt); + newArt.persist(transaction); + } + Artifact validationTestsArray[] = validationTests.toArray(new Artifact[validationTests.size()]); + + // Create Integration Test Procedure Artifacts + Set<Artifact> integrationTests = new HashSet<Artifact>(); + Artifact integrationHeader = + ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, "Integration Tests", branch); + if (integrationHeader == null) { + throw new IllegalStateException("Could not find integration Tests header"); + } + for (String str : new String[] {"X", "Y", "Z"}) { + Artifact newArt = + ArtifactTypeManager.addArtifact(CoreArtifactTypes.TestProcedure, integrationHeader.getBranch(), + "integration Test " + str); + + integrationTests.add(newArt); + integrationHeader.addRelation(CoreRelationTypes.Default_Hierarchical__Child, newArt); + newArt.persist(transaction); + } + Artifact integrationTestsArray[] = integrationTests.toArray(new Artifact[integrationTests.size()]); + + // Relate Software Artifacts to Tests + Artifact softReqsArray[] = softArts.toArray(new Artifact[softArts.size()]); + softReqsArray[0].addRelation(CoreRelationTypes.Validation__Validator, verificationTestsArray[0]); + softReqsArray[0].addRelation(CoreRelationTypes.Validation__Validator, verificationTestsArray[1]); + softReqsArray[1].addRelation(CoreRelationTypes.Validation__Validator, verificationTestsArray[0]); + softReqsArray[1].addRelation(CoreRelationTypes.Validation__Validator, validationTestsArray[1]); + softReqsArray[2].addRelation(CoreRelationTypes.Validation__Validator, validationTestsArray[0]); + softReqsArray[2].addRelation(CoreRelationTypes.Validation__Validator, integrationTestsArray[1]); + softReqsArray[3].addRelation(CoreRelationTypes.Validation__Validator, integrationTestsArray[0]); + softReqsArray[4].addRelation(CoreRelationTypes.Validation__Validator, integrationTestsArray[2]); + softReqsArray[5].addRelation(CoreRelationTypes.Validation__Validator, validationTestsArray[2]); + + for (Artifact artifact : softArts) { + artifact.persist(transaction); + } + + } + + private Collection<Artifact> getArtTypeRequirements(boolean DEBUG, IArtifactType artifactType, String artifactNameStr, IOseeBranch branch) throws OseeCoreException { + if (DEBUG) { + OseeLog.logf(AddRequirementData.class, Level.INFO, "Getting [%s] requirement(s) from Branch [%s]", + artifactNameStr, branch.getName()); + } + Collection<Artifact> arts = + ArtifactQuery.getArtifactListFromTypeAndName(artifactType, "%" + artifactNameStr + "%", branch); + if (DEBUG) { + OseeLog.logf(AddRequirementData.class, Level.INFO, "Found [%s] Artifacts", arts.size()); + } + return arts; + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddSawBranch.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddSawBranch.java new file mode 100644 index 00000000000..b373c587e3e --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddSawBranch.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2012 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.client.demo.internal; + +import org.eclipse.osee.client.demo.DemoBranches; + +/** + * @author Roberto E. Escobar + */ +public class AddSawBranch extends AbstractAddRequirementsBranch { + + public AddSawBranch() { + super(DemoBranches.SAW_Bld_1); + } +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java new file mode 100644 index 00000000000..4fdb4b551f9 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2011 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.client.demo.internal.traceability; + +import java.nio.CharBuffer; +import java.util.Collection; +import java.util.HashSet; +import org.eclipse.osee.define.traceability.ITraceParser; +import org.eclipse.osee.define.traceability.data.TraceMark; + +/** + * @author John R. Misinco + */ +public class DemoTraceParser implements ITraceParser { + + @Override + public Collection<TraceMark> getTraceMarks(CharBuffer fileBuffer) { + Collection<TraceMark> traceMarks = new HashSet<TraceMark>(); + String type = "Uses"; + traceMarks.add(new TraceMark(type, "Collaborative Robot")); + traceMarks.add(new TraceMark(type, "Robot Object")); + traceMarks.add(new TraceMark(type, "Robot Interfaces")); + traceMarks.add(new TraceMark(type, "Individual robot events")); + traceMarks.add(new TraceMark(type, "Haptic Constraints")); + + return traceMarks; + } + + @Override + public CharBuffer removeTraceMarks(CharBuffer fileBuffer) { + return fileBuffer; + } + + @Override + public boolean isTraceRemovalAllowed() { + return false; + } + +} diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceUnitResourceLocator.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceUnitResourceLocator.java new file mode 100644 index 00000000000..696ae2d5494 --- /dev/null +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceUnitResourceLocator.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2011 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.client.demo.internal.traceability; + +import java.nio.CharBuffer; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator; +import org.eclipse.osee.define.traceability.ResourceIdentifier; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author John R. Misinco + */ +public class DemoTraceUnitResourceLocator implements ITraceUnitResourceLocator { + + @Override + public boolean isValidDirectory(IFileStore fileStore) { + boolean isValid = false; + String name = fileStore.getName(); + if (Strings.isValid(name) && fileStore.fetchInfo().isDirectory()) { + isValid = !name.startsWith("."); + } + return isValid; + } + + @Override + public boolean isValidFile(IFileStore fileStore) { + boolean isValid = false; + String name = fileStore.getName(); + if (Strings.isValid(name) && !fileStore.fetchInfo().isDirectory()) { + isValid = true; + } + return isValid; + } + + @Override + public boolean hasValidContent(CharBuffer fileBuffer) { + return fileBuffer != null && fileBuffer.length() > 0; + } + + @Override + public ResourceIdentifier getIdentifier(IFileStore fileStore, CharBuffer fileBuffer) throws Exception { + return new ResourceIdentifier(fileStore.getName(), null); + } + + @Override + public IArtifactType getTraceUnitType(String name, CharBuffer fileBuffer) { + return CoreArtifactTypes.CodeUnit; + } + +} |