예제 #1
0
        public void ImportOldITARStatement_ITAR()
        {
            // There should be only an ITAR object, with attribute set to ITAR
            var acmPath = Path.Combine(testPath, "ITAR.oldstyle.acm");

            IMgaFCO fco = null;

            proj.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(fixture.proj);
                fco = importer.ImportFiles(fixture.proj, fixture.proj.GetRootDirectoryPath(), new[] { acmPath }, doNotReplaceAll: true)[1];
            });

            proj.PerformInTransaction(delegate
            {
                var comp = CyPhyClasses.Component.Cast(fco);

                var itarCollection = comp.Children.ITARCollection;
                Assert.True(itarCollection.Count() == 1);

                var itar = itarCollection.First();
                Assert.True(itar.Attributes.RestrictionLevel == CyPhyClasses.ITAR.AttributesClass.RestrictionLevel_enum.ITAR);

                Assert.False(comp.Children.DoDDistributionStatementCollection.Any());
            });
        }
예제 #2
0
        public OrganizeByCategoryFixture()
        {
            #region Set up test model and folder

            if (!Directory.Exists(PathTest))
            {
                Directory.CreateDirectory(PathTest);
            }
            if (File.Exists(PathTestXME))
            {
                File.Delete(PathTestXME);
            }
            File.Copy(PathOriginalXME, PathTestXME);

            #endregion

            String mgaConnectionString;
            GME.MGA.MgaUtils.ImportXMEForTest(PathTestXME,
                                              out mgaConnectionString);

            proj = new MgaProject();
            bool ro_mode;
            proj.Open(mgaConnectionString, out ro_mode);
            proj.EnableAutoAddOns(true);

            importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
            importer.Initialize(proj);
        }
예제 #3
0
        public void ImportCADZIP_Spring_Tungsten()
        {
            var zipPath = Path.Combine(testPath, "Spring_Tungsten.zip");

            // Import the ZIP file.
            // Check that we run without exception, have a manifest file,
            // have a folder for the component, and have 2 files in there.

            // Delete manifest and any subfolders
            File.Delete(manifestFilePath);
            if (Directory.Exists(Path.Combine(testPath, "components")))
            {
                Directory.Delete(Path.Combine(testPath, "components"), true);
            }

            var mgaProject = Common.GetProject(mgaPath);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            var mgaGateway = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result   = importer.ImportFile(mgaProject, testPath, zipPath);
                var tungsten = result.ChildObjects.Cast <IMgaFCO>().Where(x => x.Meta.Name == "Resource" && x.Name == "TUNGSTEN_SPRING.PRT").FirstOrDefault();
                Assert.Equal("CAD\\TUNGSTEN_SPRING.PRT", tungsten.StrAttrByName["Path"]);
            });
        }
예제 #4
0
        public void ZipIsMissingACM()
        {
            var zipPath = Path.Combine(testPath, "TestModel_noACM.zip");

            var mgaProject = Common.GetProject(mgaPath);

            Assert.False(mgaProject == null, "Could not load MGA project.");

            var mgaGateway = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                try
                {
                    var result = importer.ImportFile(mgaProject, testPath, zipPath);
                }
                finally
                {
                    importer.DisposeLogger();
                }
            });
        }
예제 #5
0
        public void ImportOldITARStatement_ITARDistributionD()
        {
            // There should be both an ITAR element and a DistributionD element
            var acmPath = Path.Combine(testPath, "DistD.oldstyle.acm");

            IMgaFCO fco = null;

            proj.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(fixture.proj);

                fco = importer.ImportFiles(fixture.proj, fixture.proj.GetRootDirectoryPath(), new[] { acmPath }, doNotReplaceAll: true)[1];
                importer.DisposeLogger();
            });

            proj.PerformInTransaction(delegate
            {
                var comp = CyPhyClasses.Component.Cast(fco);

                var itarCollection = comp.Children.ITARCollection;
                Assert.True(itarCollection.Count() == 1);

                var itar = itarCollection.First();
                Assert.True(itar.Attributes.RestrictionLevel == CyPhyClasses.ITAR.AttributesClass.RestrictionLevel_enum.ITAR);

                var distStatementCollection = comp.Children.DoDDistributionStatementCollection;
                Assert.True(distStatementCollection.Count() == 1);

                var distStatement = distStatementCollection.First();
                Assert.True(distStatement.Attributes.DoDDistributionStatementEnum == CyPhyClasses.DoDDistributionStatement.AttributesClass.DoDDistributionStatementEnum_enum.StatementD);
            });
        }
예제 #6
0
        public MgaFCO Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            IMgaFolder rootFolder = project.RootFolder;

            acmFilename = project.ProjectConnStr.Substring("MGA=".Length, project.ProjectConnStr.Length - ".mga".Length - "MGA=".Length);
            var component = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter().CreateComponentForAcm(project, acmFilename);

            component.StrAttrByName["Path"] = "components/../";


            return((MgaFCO)component);
        }
예제 #7
0
        public void SetUnit()
        {
            File.Copy(orgXmePathInputModel, xmePathInputModel, true);

            String connString;

            MgaUtils.ImportXMEForTest(xmePathInputModel, out connString);
            var mgaPath = connString.Substring("MGA=".Length);

            Assert.True(File.Exists(mgaPath), "Input model not found; import may have failed.");

            var project = GetProject(mgaPath);

            var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

            importer.Initialize(project);

            project.BeginTransactionInNewTerr();
            try
            {
                var fco = importer.ImportFile(project, testPath, acmPath);
                ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco);

                var millimeter = comp.Children.PropertyCollection
                                 .First(p => p.Name.Equals("mm"))
                                 .Referred.unit;
                Assert.NotNull(millimeter);
                Assert.Equal("Millimeter", millimeter.Name);

                var henry = comp.Children.PropertyCollection
                            .First(p => p.Name.Equals("Henry"))
                            .Referred.unit;
                Assert.NotNull(henry);
                Assert.Equal("Henry", henry.Name);

                var acre = comp.Children.PropertyCollection
                           .First(p => p.Name.Equals("acre"))
                           .Referred.unit;
                Assert.NotNull(acre);
                Assert.Equal("Acre", acre.Name);
            }
            finally
            {
                project.CommitTransaction();
            }

            project.Save();
            project.Close();
        }
예제 #8
0
        public static MgaFCO ImportComponentZip(MgaProject mgaProject, string zipPath)
        {
            try
            {
                CyPhyComponentImporter.CyPhyComponentImporterInterpreter importer =
                    new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

                importer.Initialize(mgaProject);

                return(importer.ImportFile(mgaProject, Path.GetDirectoryName(mgaProject.ProjectConnStr.Substring("MGA=".Length)), Path.GetFullPath(zipPath)) as MgaFCO);
            }
            catch (Exception)
            {
                throw new VFDownloadFailedException();
            }
        }
예제 #9
0
        public void ImportZIP()
        {
            var zipPath = Path.Combine(testPath, "TestModel.zip");

            // Import the ZIP file.
            // Check that we run without exception, have a manifest file,
            // have a folder for the component, and have 2 files in there.

            // Delete manifest and any subfolders
            File.Delete(manifestFilePath);
            if (Directory.Exists(Path.Combine(testPath, "components")))
            {
                Directory.Delete(Path.Combine(testPath, "components"), true);
            }

            var mgaProject = Common.GetProject(mgaPath);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            bool resultIsNull = false;
            var  mgaGateway   = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                try
                {
                    var result = importer.ImportFile(mgaProject, testPath, zipPath);
                    if (result == null)
                    {
                        resultIsNull = true;
                    }
                }
                finally
                {
                    importer.DisposeLogger();
                }
            });
            Assert.False(resultIsNull, "Exception occurred during import.");
            Assert.False(File.Exists(manifestFilePath), "Manifest erroneously generated");
        }
예제 #10
0
        public void ProjectManifestPopulationTest()
        {
            var testPath = Path.Combine(Common._importModelDirectory, "ProjectManifestPopulation");
            var xmePath  = Path.Combine(testPath, "InputModel.xme");

            var pathGeneratedManifest = Path.Combine(testPath, "manifest.project.json");

            // Delete manifest, if it exists
            if (File.Exists(pathGeneratedManifest))
            {
                File.Delete(pathGeneratedManifest);
            }

            var mgaFilename = Path.ChangeExtension(xmePath, "mga");

            GME.MGA.MgaUtils.ImportXME(xmePath, mgaFilename);

            var mgaProject = Common.GetProject(mgaFilename);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            AVM.DDP.MetaAvmProject proj = null;
            bool resultIsNull           = false;
            var  mgaGateway             = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result = importer.ImportFile(mgaProject, testPath, Path.Combine(testPath, "InputModel.component.acm"));
                if (result == null)
                {
                    resultIsNull = true;
                }

                // Load manifest while we're in a transaction
                proj = AVM.DDP.MetaAvmProject.Create(mgaProject);
            });
            Assert.False(resultIsNull, "Exception occurred during import.");
            Assert.False(File.Exists(pathGeneratedManifest), "Manifest erroneously generated");
        }
예제 #11
0
        public void ZipIsMissingResource()
        {
            var zipPath = Path.Combine(testPath, "TestModel_missingResource.zip");

            var mgaProject = Common.GetProject(mgaPath);

            Assert.False(mgaProject == null, "Could not load MGA project.");

            var mgaGateway = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                Assert.DoesNotThrow(delegate
                {
                    var result = importer.ImportFile(mgaProject, testPath, zipPath);
                });
            });
        }
예제 #12
0
        public static List <MgaFCO> ImportComponentZips(MgaProject mgaProject, List <string> zipPaths)
        {
            IMgaFCOs importedComponentFcos;

            try
            {
                CyPhyComponentImporter.CyPhyComponentImporterInterpreter importer =
                    new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

                importer.Initialize(mgaProject);

                importedComponentFcos =
                    importer.ImportFiles(mgaProject, Path.GetDirectoryName(mgaProject.ProjectConnStr.Substring("MGA=".Length)), zipPaths.ToArray());
            }
            catch (Exception)
            {
                throw new VFDownloadFailedException();
            }

            return(importedComponentFcos.OfType <MgaFCO>().ToList());
        }
예제 #13
0
        public void ImportOldITARStatement_NotITAR()
        {
            var acmPath = Path.Combine(testPath, "NotITAR.oldstyle.acm");

            IMgaFCO fco = null;

            proj.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(fixture.proj);

                fco = importer.ImportFiles(fixture.proj, fixture.proj.GetRootDirectoryPath(), new[] { acmPath }, doNotReplaceAll: true)[1];
            });

            proj.PerformInTransaction(delegate
            {
                var comp = CyPhyClasses.Component.Cast(fco);

                Assert.False(comp.Children.ITARCollection.Any());
                Assert.False(comp.Children.DoDDistributionStatementCollection.Any());
            });
        }
예제 #14
0
        public static int Main( String[] args ) {

            if( args.Length < 2 || args.Length > 4 ) usage();

            MgaProject mgaProject;
            List<String> lp_FilesToImport = new List<string>();
            string avmFilePath = "";
            string mgaProjectPath = "";
            string componentReplacementPath = "";

            bool rOptionUsed = false;
            bool pOptionUsed = false;

            for( int ix = 0 ; ix < args.Length ; ++ix ) {

                if( args[ ix ].ToLower() == "-r" ) {

                    if( pOptionUsed ) usage();
                    rOptionUsed = true;

                    if ( ++ix >= args.Length ) usage();

                    if( avmFilePath != null && avmFilePath != "" ) {
                        if( mgaProjectPath != null && mgaProjectPath != "" ) usage();
                        mgaProjectPath = avmFilePath;
                        avmFilePath = "";
                        lp_FilesToImport.Clear();
                    }

                    String sImportDirectory = args[ ix ];

                    String startingDirectory = Path.GetFullPath( sImportDirectory );
                    string[] xmlFiles = Directory.GetFiles( startingDirectory, "*.acm", SearchOption.AllDirectories );

                    foreach( String p_XMLFile in xmlFiles ) {
                        lp_FilesToImport.Add( Path.GetFullPath( p_XMLFile ) );
                    }

                } else if( args[ ix ].ToLower() == "-p" ) {

                    if( rOptionUsed ) usage();
                    pOptionUsed = true;

                    if ( ++ix >= args.Length ) usage();
                    componentReplacementPath = args[ ix ];

                } else if ( lp_FilesToImport.Count == 0 && avmFilePath == "" ) {

                    avmFilePath = args[ ix ];
                    try
                    {
                        lp_FilesToImport.Add(Path.GetFullPath(avmFilePath));
                    }
                    catch (System.ArgumentException ex)
                    {
                        Console.Out.WriteLine(ex.Message);
                        Console.Out.WriteLine(avmFilePath);
                        throw ex;
                    }

                } else {

                    if( mgaProjectPath != null && mgaProjectPath != "" ) usage();
                    mgaProjectPath = args[ ix ];
                }

            }


            mgaProject = GetProject( mgaProjectPath );
            try
            {
                bool bExceptionOccurred = false;
                if (mgaProject != null)
                {
                    MgaGateway mgaGateway = new MgaGateway(mgaProject);

                    mgaProject.CreateTerritoryWithoutSink(out mgaGateway.territory);
                    mgaGateway.PerformInTransaction(delegate
                    {

                        string libroot = Path.GetDirectoryName(Path.GetFullPath(mgaProjectPath));

                        CyPhyML.RootFolder cyPhyMLRootFolder = ISIS.GME.Common.Utils.CreateObject<CyPhyMLClasses.RootFolder>(mgaProject.RootFolder as MgaObject);

                        #region Attach QUDT library if needed
                        IMgaFolder oldQudt = mgaProject.RootFolder.ChildFolders.Cast<IMgaFolder>().Where(x => x.LibraryName != "" && (x.Name.ToLower().Contains("qudt"))).FirstOrDefault();
                        string mgaQudtPath = Meta_Path + "\\meta\\CyPhyMLQudt.mga";

                        bool needAttach = false;
                        if (oldQudt == null)
                        {

                            needAttach = true;

                        }
                        else
                        {

                            long loldModTime;
                            DateTime oldModTime = long.TryParse(oldQudt.RegistryValue["modtime"], out loldModTime) ? DateTime.FromFileTimeUtc(loldModTime) : DateTime.MinValue;
                            needAttach = System.IO.File.GetLastWriteTimeUtc(mgaQudtPath).CompareTo(oldModTime) > 0;
                            if (!needAttach)
                            {
                                Console.Error.WriteLine("QUDT is up-to-date: embedded library modified " + oldModTime.ToString() + ", CyPhyMLQudt.mga modified " + System.IO.File.GetLastWriteTimeUtc(mgaQudtPath).ToString());
                            }
                        }

                        if (needAttach)
                        {

                            Console.Error.WriteLine("Attaching library " + mgaQudtPath);
                            ISIS.GME.Common.Interfaces.RootFolder newQudt = ISIS.GME.Common.Classes.RootFolder.GetRootFolder(mgaProject).AttachLibrary("MGA=" + mgaQudtPath);
                            DateTime modtime = System.IO.File.GetLastWriteTimeUtc(mgaQudtPath);
                            ((newQudt as ISIS.GME.Common.Classes.RootFolder).Impl as GME.MGA.IMgaFolder).RegistryValue["modtime"] =
                                    modtime.ToFileTimeUtc().ToString();

                            if (oldQudt != null)
                            {
                                ReferenceSwitcher.Switcher sw = new ReferenceSwitcher.Switcher(oldQudt, newQudt.Impl, null);
                                sw.UpdateSublibrary();
                                oldQudt.DestroyObject();
                            }
                            ((newQudt as ISIS.GME.Common.Classes.RootFolder).Impl as GME.MGA.IMgaFolder).LibraryName = "UnitLibrary QUDT";
                            Console.Error.WriteLine((oldQudt == null ? "Attached " : "Refreshed") + " Qudt library.");
                        }
                        #endregion

                        var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                        importer.Initialize(cyPhyMLRootFolder.Impl.Project);
                        importer.ImportFiles(cyPhyMLRootFolder.Impl.Project, libroot, lp_FilesToImport.ToArray(), true);
                        bExceptionOccurred = importer.Errors.Count > 0;
                    });

                    mgaProject.Save();

                    if (mgaGateway.territory != null)
                    {
                        mgaGateway.territory.Destroy();
                    }

                    if (bExceptionOccurred)
                    {
                        return -1;
                    }
                }
            }
            finally
            {
                mgaProject.Close(true);
            }
            return 0;
        }
예제 #15
0
        public static int Main(String[] args)
        {
            if (args.Length < 2 || args.Length > 4)
            {
                usage();
                return(1);
            }
            MgaProject    mgaProject;
            List <String> lp_FilesToImport         = new List <string>();
            string        avmFilePath              = "";
            string        mgaProjectPath           = "";
            string        componentReplacementPath = "";

            bool rOptionUsed = false;
            bool pOptionUsed = false;

            for (int ix = 0; ix < args.Length; ++ix)
            {
                if (args[ix].ToLower() == "-r")
                {
                    if (pOptionUsed)
                    {
                        usage();
                        return(1);
                    }
                    rOptionUsed = true;

                    if (++ix >= args.Length)
                    {
                        usage();
                        return(1);
                    }

                    if (avmFilePath != null && avmFilePath != "")
                    {
                        if (mgaProjectPath != null && mgaProjectPath != "")
                        {
                            usage();
                            return(1);
                        }
                        mgaProjectPath = avmFilePath;
                        avmFilePath    = "";
                        lp_FilesToImport.Clear();
                    }

                    String sImportDirectory = args[ix];

                    String   startingDirectory = Path.GetFullPath(sImportDirectory);
                    string[] xmlFiles          = Directory.GetFiles(startingDirectory, "*.acm", SearchOption.AllDirectories);

                    foreach (String p_XMLFile in xmlFiles)
                    {
                        lp_FilesToImport.Add(Path.GetFullPath(p_XMLFile));
                    }
                }
                else if (args[ix].ToLower() == "-p")
                {
                    if (rOptionUsed)
                    {
                        usage();
                        return(1);
                    }
                    pOptionUsed = true;

                    if (++ix >= args.Length)
                    {
                        usage();
                        return(1);
                    }
                    componentReplacementPath = args[ix];
                }
                else if (lp_FilesToImport.Count == 0 && avmFilePath == "")
                {
                    avmFilePath = args[ix];
                    try
                    {
                        lp_FilesToImport.Add(Path.GetFullPath(avmFilePath));
                    }
                    catch (System.ArgumentException ex)
                    {
                        Console.Out.WriteLine(ex.Message);
                        Console.Out.WriteLine(avmFilePath);
                        throw ex;
                    }
                }
                else
                {
                    if (mgaProjectPath != null && mgaProjectPath != "")
                    {
                        usage();
                        return(1);
                    }
                    mgaProjectPath = args[ix];
                }
            }


            mgaProject = GetProject(mgaProjectPath);
            try
            {
                bool bExceptionOccurred = false;
                if (mgaProject != null)
                {
                    MgaGateway mgaGateway = new MgaGateway(mgaProject);

                    mgaGateway.PerformInTransaction(delegate
                    {
                        string libroot = Path.GetDirectoryName(Path.GetFullPath(mgaProjectPath));

                        CyPhyML.RootFolder cyPhyMLRootFolder = ISIS.GME.Common.Utils.CreateObject <CyPhyMLClasses.RootFolder>(mgaProject.RootFolder as MgaObject);

                        #region Attach QUDT library if needed
                        IMgaFolder oldQudt = mgaProject.RootFolder.ChildFolders.Cast <IMgaFolder>().Where(x => x.LibraryName != "" && (x.Name.ToLower().Contains("qudt"))).FirstOrDefault();
                        string mgaQudtPath = Meta_Path + "\\meta\\CyPhyMLQudt.mga";

                        bool needAttach = false;
                        if (oldQudt == null)
                        {
                            needAttach = true;
                        }
                        else
                        {
                            long loldModTime;
                            DateTime oldModTime = long.TryParse(oldQudt.RegistryValue["modtime"], out loldModTime) ? DateTime.FromFileTimeUtc(loldModTime) : DateTime.MinValue;
                            needAttach          = System.IO.File.GetLastWriteTimeUtc(mgaQudtPath).CompareTo(oldModTime) > 0;
                            if (!needAttach)
                            {
                                Console.Error.WriteLine("QUDT is up-to-date: embedded library modified " + oldModTime.ToString() + ", CyPhyMLQudt.mga modified " + System.IO.File.GetLastWriteTimeUtc(mgaQudtPath).ToString());
                            }
                        }

                        if (needAttach)
                        {
                            Console.Error.WriteLine("Attaching library " + mgaQudtPath);
                            ISIS.GME.Common.Interfaces.RootFolder newQudt = ISIS.GME.Common.Classes.RootFolder.GetRootFolder(mgaProject).AttachLibrary("MGA=" + mgaQudtPath);
                            DateTime modtime = System.IO.File.GetLastWriteTimeUtc(mgaQudtPath);
                            ((newQudt as ISIS.GME.Common.Classes.RootFolder).Impl as GME.MGA.IMgaFolder).RegistryValue["modtime"] =
                                modtime.ToFileTimeUtc().ToString();

                            if (oldQudt != null)
                            {
                                ReferenceSwitcher.Switcher sw = new ReferenceSwitcher.Switcher(oldQudt, newQudt.Impl, null);
                                sw.UpdateSublibrary();
                                oldQudt.DestroyObject();
                            }
                            ((newQudt as ISIS.GME.Common.Classes.RootFolder).Impl as GME.MGA.IMgaFolder).LibraryName = "UnitLibrary QUDT";
                            Console.Error.WriteLine((oldQudt == null ? "Attached " : "Refreshed") + " Qudt library.");
                        }
                        #endregion

                        var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                        importer.Initialize(cyPhyMLRootFolder.Impl.Project);
                        importer.ImportFiles(cyPhyMLRootFolder.Impl.Project, libroot, lp_FilesToImport.ToArray(), true);
                        importer.DisposeLogger();
                        bExceptionOccurred = importer.Errors.Count > 0;
                    }, abort: false);

                    mgaProject.Save();

                    if (bExceptionOccurred)
                    {
                        return(-1);
                    }
                }
            }
            finally
            {
                mgaProject.Close(true);
            }
            return(0);
        }
예제 #16
0
파일: Clm.cs 프로젝트: neemask/meta-core
        public static List<MgaFCO> ImportComponentZips(MgaProject mgaProject, List<string> zipPaths)
        {
            IMgaFCOs importedComponentFcos;

            try
            {
                CyPhyComponentImporter.CyPhyComponentImporterInterpreter importer =
                    new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

                importer.Initialize(mgaProject);

                importedComponentFcos =
                    importer.ImportFiles(mgaProject, Path.GetDirectoryName(mgaProject.ProjectConnStr.Substring("MGA=".Length)), zipPaths.ToArray());
            }
            catch (Exception)
            {
                throw new VFDownloadFailedException();
            }

            return importedComponentFcos.OfType<MgaFCO>().ToList();
        }
예제 #17
0
파일: Clm.cs 프로젝트: neemask/meta-core
        public static MgaFCO ImportComponentZip(MgaProject mgaProject, string zipPath)
        {
            try
            {
                CyPhyComponentImporter.CyPhyComponentImporterInterpreter importer =
                    new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

                importer.Initialize(mgaProject);

                return importer.ImportFile(mgaProject, Path.GetDirectoryName(mgaProject.ProjectConnStr.Substring("MGA=".Length)), Path.GetFullPath(zipPath)) as MgaFCO;
            }
            catch (Exception)
            {
                throw new VFDownloadFailedException();
            }
        }
예제 #18
0
        public void ProjectManifestPopulationTest()
        {
            var testPath = Path.Combine(Common._importModelDirectory, "ProjectManifestPopulation");
            var xmePath = Path.Combine(testPath, "InputModel.xme");

            var pathGeneratedManifest = Path.Combine(testPath, "manifest.project.json");
            // Delete manifest, if it exists
            if (File.Exists(pathGeneratedManifest))
                File.Delete(pathGeneratedManifest);

            var mgaFilename = Path.ChangeExtension(xmePath, "mga");
            GME.MGA.MgaUtils.ImportXME(xmePath, mgaFilename);

            var mgaProject = Common.GetProject( mgaFilename );
            Assert.True(mgaProject != null,"Could not load MGA project.");

            AVM.DDP.MetaAvmProject proj = null;
            bool resultIsNull = false;
            var mgaGateway = new MgaGateway(mgaProject);
            mgaProject.CreateTerritoryWithoutSink(out mgaGateway.territory);
            mgaGateway.PerformInTransaction(delegate {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result = importer.ImportFile(mgaProject,testPath,Path.Combine(testPath,"InputModel.component.acm"));
                if (result == null)
                    resultIsNull = true;

                // Load manifest while we're in a transaction
                proj = AVM.DDP.MetaAvmProject.Create(mgaProject);
            });
            Assert.False(resultIsNull,"Exception occurred during import.");
            Assert.False(File.Exists(pathGeneratedManifest), "Manifest erroneously generated");
        }
예제 #19
0
        public void SetUnit()
        {
            File.Copy(orgXmePathInputModel, xmePathInputModel, true);

            String connString;
            MgaUtils.ImportXMEForTest(xmePathInputModel, out connString);
            var mgaPath = connString.Substring("MGA=".Length);
            Assert.True(File.Exists(mgaPath), "Input model not found; import may have failed.");

            var project = GetProject(mgaPath);

            var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
            importer.Initialize(project);

            project.PerformInTransaction(delegate
            {
                var fco = importer.ImportFile(project, testPath, acmPath);
                ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco);
                
                var millimeter = comp.Children.PropertyCollection
                                              .First(p => p.Name.Equals("mm"))
                                              .Referred.unit;
                Assert.NotNull(millimeter);
                Assert.Equal("Millimeter", millimeter.Name);

                var henry = comp.Children.PropertyCollection
                                         .First(p => p.Name.Equals("Henry"))
                                         .Referred.unit;
                Assert.NotNull(henry);
                Assert.Equal("Henry", henry.Name);

                var acre = comp.Children.PropertyCollection
                                        .First(p => p.Name.Equals("acre"))
                                        .Referred.unit;
                Assert.NotNull(acre);
                Assert.Equal("Acre", acre.Name);
            });

            project.Save();
            project.Close();
        }