Description of MappingLogic.
Наследование: MappingFramework.MappingLogic
Пример #1
0
        protected override void saveMe()
        {
            var logicString = MappingLogic.getMappingLogicString(this.EAMappingLogics);

            addTaggedValueSafe(MappingFactory.mappingLogicName, logicString);

            //set mapping path
            if (this.source.structure == MP.ModelStructure.Message || this.source.isVirtual)
            {
                addTaggedValueSafe(MappingFactory.mappingSourcePathName, string.Join(".", ((MappingNode)this.source).mappingPath));
            }
            if (this.target.structure == MP.ModelStructure.Message || this.target.isVirtual)
            {
                addTaggedValueSafe(MappingFactory.mappingTargetPathName, string.Join(".", ((MappingNode)this.target).mappingPath));
            }
            this.wrappedConnector.save();
        }
Пример #2
0
        protected override List <MappingLogic> loadMappingLogics()
        {
            var logicString = this.getTaggedValueSafe(MappingFactory.mappingLogicName);

            return(MappingLogic.getMappingLogicsFromString(logicString, this.wrappedConnector.EAModel));
        }
 public Mapping(MappingNode sourceEnd, MappingNode targetEnd, MappingLogic logic) : this(sourceEnd, targetEnd)
 {
     this._mappingLogic = logic;
 }
Пример #4
0
        /// <summary>
        /// create a mappingSet based on the data in the CSV file
        /// </summary>
        /// <param name="model">the model that contains the elements</param>
        /// <param name="filePath">the path to the CSV file</param>
        /// <returns>a mapping set representing the mapping in the file</returns>
        public static MappingSet createMappingSet(Model model, string filePath, MappingSettings settings, Element sourceRootElement = null, Element targetRootElement = null)
        {
            MappingSet newMappingSet = null;
            var        engine        = new FileHelperEngine <CSVMappingRecord>();
            var        parsedFile    = engine.ReadFile(filePath);
            int        i             = 1;
            Package    rootPackage   = null;

            foreach (CSVMappingRecord mappingRecord in parsedFile)
            {
                //find source
                var source = findElement(model, mappingRecord.sourcePath, sourceRootElement);
                //find target
                var target = findElement(model, mappingRecord.targetPath, targetRootElement);
                if (source == null)
                {
                    EAOutputLogger.log(model, settings.outputName
                                       , string.Format("Could not find element that matches: '{0}'", mappingRecord.sourcePath)
                                       , 0, LogTypeEnum.error);
                }
                else if (target == null)
                {
                    EAOutputLogger.log(model, settings.outputName
                                       , string.Format("Could not find element that matches: '{0}'", mappingRecord.targetPath)
                                       , 0, LogTypeEnum.error);
                }
                else
                {
                    //first check if the mappingSet is already created
                    if (newMappingSet == null)
                    {
                        //determine if this should be a PackageMappingSet or an ElementMappingSet
                        if (sourceRootElement is Package)
                        {
                            rootPackage   = sourceRootElement as Package;
                            newMappingSet = new PackageMappingSet(sourceRootElement as Package);
                        }
                        else if (sourceRootElement is ElementWrapper)
                        {
                            rootPackage   = sourceRootElement.owningPackage as Package;
                            newMappingSet = new ElementMappingSet(sourceRootElement as ElementWrapper);
                        }
                        else
                        {
                            rootPackage   = source.owningPackage as Package;
                            newMappingSet = new PackageMappingSet((Package)source.owningPackage);
                        }
                    }
                    MappingLogic newMappingLogic = null;
                    //check if there is any mapping logic
                    if (!string.IsNullOrEmpty(mappingRecord.mappingLogic))
                    {
                        if (settings.useInlineMappingLogic)
                        {
                            newMappingLogic = new MappingLogic(mappingRecord.mappingLogic);
                        }
                        else
                        {
                            //Check fo an existing mapping logic
                            newMappingLogic = getExistingMappingLogic(model, settings, mappingRecord.mappingLogic, rootPackage);

                            if (newMappingLogic == null)
                            {
                                var mappingElement = model.factory.createNewElement(rootPackage, "mapping logic " + i, settings.mappingLogicType) as ElementWrapper;
                                if (mappingElement != null)
                                {
                                    //increase counter for new mapping element name
                                    i++;
                                    mappingElement.notes = mappingRecord.mappingLogic;
                                    mappingElement.save();
                                    //create the mappingLogic
                                    newMappingLogic = new MappingLogic(mappingElement);
                                }
                                else
                                {
                                    //else we create an inline mapping logic anyway
                                    newMappingLogic = new MappingLogic(mappingRecord.mappingLogic);
                                }
                            }
                        }
                    }
                    Mapping newMapping           = null;
                    var     sourceAssociationEnd = source as AssociationEnd;
                    var     targetAssociationEnd = target as AssociationEnd;
                    //create the new mapping
                    //we can't create connector mappings for mappings to or from associations so we have to use tagged value mappings for those.
                    if (settings.useTaggedValues ||
                        sourceAssociationEnd != null || targetAssociationEnd != null)
                    {
                        //if the source or target are associationEnds then we replace them by their association
                        if (sourceAssociationEnd != null)
                        {
                            source = sourceAssociationEnd.association as Element;
                        }
                        if (targetAssociationEnd != null)
                        {
                            target = targetAssociationEnd.association as Element;
                        }
                        newMapping = new TaggedValueMapping(source, target, mappingRecord.sourcePath, mappingRecord.targetPath, settings);
                    }
                    else
                    {
                        newMapping = new ConnectorMapping(source, target, mappingRecord.sourcePath, mappingRecord.targetPath, settings);
                    }
                    if (newMappingLogic != null)
                    {
                        newMapping.mappingLogic = newMappingLogic;
                    }
                    newMapping.save();
                    newMappingSet.addMapping(newMapping);
                }
            }
            return(newMappingSet);
        }
 public Mapping(MappingEnd sourceEnd, MappingEnd targetEnd, MappingLogic logic)
     : this(sourceEnd,targetEnd)
 {
     _mappingLogic = logic;
 }
Пример #6
0
 public Mapping(MappingEnd sourceEnd, MappingEnd targetEnd, MappingLogic logic) : this(sourceEnd, targetEnd)
 {
     _mappingLogic = logic;
 }