Ejemplo n.º 1
0
        public CoreInterface(TmpInterface tmp, CoreModel model)
        {
            coreModel        = model;
            BaseData         = tmp;
            Name             = tmp.Name;
            FormerName       = null;
            Type             = ToInterfaceType(tmp.Type);
            WhitespaceBefore = tmp.WhitespaceBefore;
            IsHistorized     = false;
            IsWithNowTable   = false;

            // Interface-Parameter ggf. setzen
            if (tmp.Parameters != null && tmp.Parameters.Where(p => p.Name == "mandant" && p.Value == "true").Count() > 0)
            {
                IsMandant = true;
            }
            if (tmp.Parameters != null && tmp.Parameters.Where(p => p.Name == "former_name").Count() > 0)
            {
                FormerName = tmp.Parameters.Where(p => p.Name == "former_name").First().Value;
            }
            if (tmp.Parameters != null && tmp.Parameters.Where(p => p.Name == "with_nowtable" && p.Value == "true").Count() > 0)
            {
                IsWithNowTable = true;
            }
            if (tmp.Parameters != null && tmp.Parameters.Where(p => p.Name == "history" && p.Value == "true").Count() > 0)
            {
                IsHistorized = true;
            }
            if (tmp.Parameters != null && tmp.Parameters.Where(p => p.Name == "calculated" && p.Value == "true").Count() > 0)
            {
                IsCalculated = true;
            }

            // Prüfung semantischer Regeln der Sprache CEUSDL (ausfiltern ungültiger Parameterkombinationen)
            if (Type == CoreInterfaceType.TEMPORAL_TABLE && IsMandant)
            {
                throw new InvalidParameterException($"Fehler in Interface {Name}: Eine TemporalTable kann nicht Mandantabhängig sein");
            }
            if (Type == CoreInterfaceType.TEMPORAL_TABLE && tmp.Parameters.Where(p => p.Name == "history").Count() > 0)
            {
                throw new InvalidParameterException($"Fehler in Interface {Name}: Eine TemporalTable kann nicht historisiert werden");
            }
            if (Type != CoreInterfaceType.FACT_TABLE && IsWithNowTable)
            {
                throw new InvalidParameterException($"Fehler in Interface {Name}: Now-Tables sind nur für FactTables zulässig");
            }
            if (IsWithNowTable && !IsHistorized)
            {
                throw new InvalidParameterException($"Fehler in Interface {Name}: Now-Tables sind nur für historisierte Tabellen zulässig");
            }

            if (tmp.Parameters != null &&
                (
                    tmp.Parameters.Where(a => a.Name == "finest_time_attribute" && a.Value == "true").Count() > 0 ||
                    tmp.Parameters.Where(a => a.Name == "history_attribute" && a.Value == "true").Count() > 0
                ))
            {
                // Prüfung: InterfaceType muss TemporalTable sein
                if (Type != CoreInterfaceType.TEMPORAL_TABLE)
                {
                    throw new InvalidParameterException($"Fehler in Interface {Name}: Nur TemporalTables können finest_time_attribute sein");
                }

                // Prüfung: Nur eine Tabelle kann finest_time_attribute sein
                if (model.Interfaces.Where(i => i.IsFinestTime).Count() > 0)
                {
                    throw new InvalidParameterException($"Fehler in Interface {Name}: Nur ein Interface kann finest_time_attribute sein");
                }

                IsFinestTime = true;
            }

            ItemObjects = new List <CoreItemLevelObject>();

            foreach (var tmpObj in tmp.ItemObjects)
            {
                if (tmpObj.IsAttribute)
                {
                    var           tmpAttr = tmpObj.Attribute;
                    CoreAttribute attr    = null;
                    switch (tmpAttr.AttributeType)
                    {
                    case "base":
                        attr = new CoreBaseAttribute(tmpAttr, this, model);
                        break;

                    case "ref":
                        attr = new CoreRefAttribute(tmpAttr, this, model);
                        break;

                    case "fact":
                        attr = new CoreFactAttribute(tmpAttr, this, model);
                        break;

                    default:
                        throw new InvalidAttributeTypeException($"Ungültiger Attribut-Typ {tmpAttr.AttributeType} in Interface {tmp.Name} gefunden");
                    }
                    ItemObjects.Add(attr);
                }
                else if (tmpObj.IsComment)
                {
                    ItemObjects.Add(new CoreComment(tmpObj.Comment));
                }
                else
                {
                    throw new InvalidDataTypeException();
                }
            }
            // Info: Ref-Attribute werden im Postprocessing aufgelöst.
        }
Ejemplo n.º 2
0
 public CoreRefAttribute(TmpInterfaceAttribute tmp, CoreInterface parent, CoreModel model) : base(tmp, parent, model)
 {
     this.Alias = tmp.Alias;
 }