Beispiel #1
0
        public override void Save(IContainer entityToSerialize)
        {
            var fileName = _interactionTask.AskForFileToSave(AppConstants.Captions.Save, Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART, entityToSerialize.Name);

            if (fileName.IsNullOrEmpty())
            {
                return;
            }

            var tmpSpatialStructure = (IMoBiSpatialStructure)_spatialStructureFactory.Create();

            // make a backup of the parent and reset that after as there is a side effect
            // of removing the reference to parent container.
            var parent = entityToSerialize.ParentContainer;

            tmpSpatialStructure.AddTopContainer(entityToSerialize);
            entityToSerialize.ParentContainer = parent;
            var existingSpatialStructure = _interactionTaskContext.Active <IMoBiSpatialStructure>();

            if (existingSpatialStructure != null)
            {
                var neighborhoods = getConnectingNeighborhoods(new[] { entityToSerialize }, existingSpatialStructure);
                neighborhoods.Each(tmpSpatialStructure.AddNeighborhood);
                if (existingSpatialStructure.DiagramModel != null)
                {
                    tmpSpatialStructure.DiagramModel = existingSpatialStructure.DiagramModel.CreateCopy(entityToSerialize.Id);
                }
            }

            _interactionTask.Save(tmpSpatialStructure, fileName);
        }
Beispiel #2
0
        /// <summary>
        ///     Creates the Spatial Structure of the SBML Model with the TopContainer.
        /// </summary>
        internal void CreateSpatialStructureFromModel(IContainer topContainer, Model model)
        {
            SpatialStructure = _spatialStructureFactory.Create().DowncastTo <IMoBiSpatialStructure>()
                               .WithName(SBMLConstants.SBML_MODEL + model.getName())
                               .WithTopContainer(topContainer)
                               .WithDescription(SBMLConstants.SBML_NOTES + model.getNotesString() + SBMLConstants.SPACE +
                                                SBMLConstants.SBML_METAID + model.getMetaId());

            SpatialStructure.AddTopContainer(_eventsTopContainer);
        }