Ejemplo n.º 1
0
        // синхронизация связей объекта
        void syncRoles(FC.FeatureType obj, xobj.Iroles roles)
        {
            roles.beginUpdate();

            int count=syncParentRoles(obj,roles);
            count+= addRoles(obj,obj,roles);

            int rc;
            roles.endUpdate(obj.Code,out rc);

            if (rc < 0) __err(); else {
                if (count > 0) froleCount++;
                if (rc == 1) froleUpdCount++; else
                if (rc == 2) froleNewCount++;
            }
        }
Ejemplo n.º 2
0
        // синхронизация родительских связей
        int syncParentRoles(FC.FeatureType obj, xobj.Iroles roles)
        {
            var count=0;

            var parents = obj.InheritsFrom;
            if (parents != null)
            foreach (var parent in parents) {
                FC.FeatureType up=parent.Supertype;
                if (up != null) {
                    count += syncParentRoles(up, roles);
                    count += addRoles(obj,up,roles);
                }
            }

            return count;
        }
Ejemplo n.º 3
0
        // синхронизация родительских бланков
        int syncParentDT(xobj.Iblank blank, FC.FeatureType dt)
        {
            var rc =0;
            var parents = dt.InheritsFrom;
            if (parents != null)
            foreach (var parent in parents) {
                FC.FeatureType up=parent.Supertype;
                if (up != null) {
                    string s=up.Code;
                    if (convert.IsString(s))
                    if (syncDT(up) > 0) {
                        int rc1;
                        if (!up.IsDataType()) s="$"+s;
                        blank.attr("$inherited","",s,0,out rc1);
                        if (rc1 < 0) __err(); else rc++;
                    }
                }
            }

            return rc;
        }
Ejemplo n.º 4
0
        // синхронизация атрибута
        bool syncAttr(xobj.Iblank blank, FC.Binding binding)
        {
            var attr = binding.PropertyType as FC.FeatureAttribute;

            if (attr != null) {

                string key=attr.Code;	// акроним
                if (convert.IsString(key)) {

                    int rc;

                    string typ=attr.ValueType;

                    FC.FeatureType dt=null;
                    string dt1="";

                    if (typ == "Класс") {
                        dt=binding.GetDataType();
                        if (dt != null) dt1=dt.Code;
                    }

               					string Nset=binding.Cardinality;

                    int flags=0;

                    if (!binding.Voidable) flags+=1;

                    if (typ == "Домен") {
                        var vt = binding.ConstrainedBy.GetConstraint( typeof(ValueTypeConstraint) ) as
                            FC.ValueTypeConstraint.DomainValueType;
                        if (vt != null) if (vt.IsMultiValue) flags+=8;
                    } else

                    if (typ == "Дробное интервальное") flags+=8;

                    if (!fattrList.Contains(key)) {

                        fattrList.Add(key);

              					if (dt != null) syncDT(dt);
              					if (typ == "Домен") {
              						rc=syncEnum(attr);
              						if (rc == 0) typ="dbase";
              					}

                        string capt=attr.ToString();
                        fidx.sync(key,typ,capt,out rc);

                        if (rc == 1) fattrUpdCount++; else
                        if (rc == 2) fattrNewCount++; else
                        if (rc != 0) __err();
                    }

                    blank.attr(key,Nset,dt1,flags,out rc);

                    if (rc < 0) __err();

                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 5
0
        // добавить связи объекта
        int addRoles(FC.FeatureType owner,
					 FC.FeatureType obj,
		             xobj.Iroles roles)
        {
            int count=0;

            foreach (var binding in obj.Bindings) {
                var role = binding.PropertyType as FC.AssociationRole;

                if (role != null)
                if (role.IsNavigable) {

                    FC.FeatureType dest = role.ValueType;
                    if (dest != null) {

              						string Nset=binding.Cardinality;

                        var childs = dest.InheritsTo;
                        if (childs != null)
                        if (childs.Count == 0)
                        childs=null;

                        if (childs == null) {
              						bool rc=addRole(roles,owner,role,dest,Nset);
              						if (rc) count++;
                        }
                        else {
                            foreach(var child in childs) {
                                FC.FeatureType dest1=child.Subtype;
              						bool rc=addRole(roles,owner,role,dest1,Nset);
              						if (rc) count++;
                            }
                        }
                    }
              				}
            }

            return count;
        }
Ejemplo n.º 6
0
        bool addRole(xobj.Iroles roles,
					 FC.FeatureType owner,
					 FC.AssociationRole role,
		             FC.FeatureType dest, 
		             string Nset)
        {
            FC.AssociationRole.RoleType typ=role.Type;

            string key=role.Code;
            string name=role.MemberName;
            string hf="";
            string tp="";

            var es = owner.ConstrainedBy.GetConstraint( typeof(AssociationRoleConstraint) ) as FC.AssociationRoleConstraint;

            if (es != null) {
                foreach(var e in es.ValidationRules)
                if (e.AssociationRoleName == name) {
                    hf=e.ОграничениеПоСемантике; break;
                }

                foreach(var e in es.TopologicRules)
                if (e.AssociationRoleName == name) {

                    string t=GeomToInt(e.SourceGeom)+","+
                             GeomToInt(e.TargetGeom)+","+
                             e.ОграничениеПоТопологии;

                    if (tp.Length > 0) tp+="/";
                    tp+=t;
                }
            }

              			string s="";
              			if (key != null) s=key;
              			if (name.Length > 0) {
              				if (s.Length > 0) s+="/";
              				s+=name;
              			}

              			int rc;
              			roles.role(s,((int) typ)-1,dest.Code,Nset,hf,tp,out rc);
              			if (rc < 0) { __err(); return false; }

            return true;
        }