Ejemplo n.º 1
0
        public override void Init( IProject project, IDependencyManager dependencies, IBuildAggregator aggregator )
        {
            base.Init( project, dependencies, aggregator );
            Model model = project.Model;

            EntityClass quotes = new EntityClass();
            quotes.Name = "QuoteOfTheDay";
            quotes.Visibility = "public";

            EntityField id = new EntityField();
            id.Name = "id";
            id.IsPreview = true;
            id.IsPrimaryKey = true;
            id.Type = IntrinsicTypes.Create("System.Int32");
            quotes.Fields.Add(id);

            EntityField quote = new EntityField();
            quote.Name = "quote";
            quote.Represents = true;
            quote.IsPreview = true;
            quote.Type = IntrinsicTypes.Create( "System.String" );
            quote.IsRequired = true;
            quote.MaxSize = 1000;
            quotes.Fields.Add(quote);

            model.Add(quotes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return the representation of the entities that the parameter entity depends
        /// </summary>
        public RelationDependency create(EntityClass entity, Model model)
        {
            RelationDependency toReturn = new RelationDependency(entity.Name);
            if (entityNames.Contains(entity.Name))
            {
                toReturn.IsReusable = true;
            }
            else
            {
                entityNames.Add(entity.Name);
            }
            foreach (EntityField field in entity.Fields)
            {
                if( field.Mult == Multiplicity.ManyToOne /*|| field.Mult == Multiplicity.ManyToMany*/)
                {
                    //RelationDependency relates = create((EntityClass)model[ GetEntityIndex(field.Type.Name, model) ], entity, model);
                    //toReturn.Dependencies.Add(relates);
                    toReturn.Dependencies.Add(create((EntityClass)model[ GetEntityIndex(field.Type.Name, model) ], model));
                }
            }

            if (entity.HasParent)
            {
                foreach (EntityField field in ((EntityClass)entity.Parent).Fields)
                {
                    if( field.Mult == Multiplicity.ManyToOne /*|| field.Mult == Multiplicity.ManyToMany */)
                    {
                        toReturn.Dependencies.Add(create((EntityClass)model[ GetEntityIndex(field.Type.Name, model) ], model));
                    }
                }
            }
            return toReturn;
        }
Ejemplo n.º 3
0
        private EntityClass CreateLogger()
        {
            Entity intEntity = IntrinsicTypes.Create( "System.Int32" );
            Entity stringEntity = IntrinsicTypes.Create( "System.String" );
            Entity dateTimeEntity = IntrinsicTypes.Create( "System.DateTime" );

            EntityClass logger = new EntityClass();
            logger.Name = "RequestLogger";
            logger.Visibility = "public";

            EntityField field = new EntityField();
            field.Name = "id";
            field.IsPrimaryKey = true;
            field.IsPreview = true;
            field.Type = intEntity;
            logger.Fields.Add(field);

            field = new EntityField();
            field.Name = "url";
            field.IsPreview = true;
            field.Represents = true;
            field.Type = stringEntity;
            field.MaxSize = 1000;
            logger.Fields.Add(field);

            field = new EntityField();
            field.Name = "date";
            field.IsPreview = true;
            field.Type = dateTimeEntity;
            logger.Fields.Add(field);

            field = new EntityField();
            field.Name = "requestTime";
            field.IsPreview = true;
            field.Type = intEntity;
            logger.Fields.Add(field);

            field = new EntityField();
            field.Name = "referrer";
            field.Type = stringEntity;
            field.IsRequired = false;
            field.MaxSize = 1000;
            logger.Fields.Add(field);

            field = new EntityField();
            field.Name = "ip";
            field.Type = stringEntity;
            field.MaxSize = 15;
            logger.Fields.Add(field);

            field = new EntityField();
            field.Name = "userAgent";
            field.Type = stringEntity;
            field.MaxSize = 1500;
            logger.Fields.Add(field);

            return logger;
        }
Ejemplo n.º 4
0
        private static void BuildClassTestModel()
        {
            EntityInterface iPerson = GetInterface();
            EntityClass parent = new EntityClass();
            parent.Name = "Pai";
            EntityClass category = new EntityClass();
            category.Name = "Category";
            category.Visibility = "public";
            category.Interfaces.Add(iPerson);
            category.Parent = parent;

            EntityField field = new EntityField();
            field.Name = "Id";
            field.Visibility = "protected";
            field.IsPrimaryKey = true;
            field.Type = new Int();
            category.Fields.Add(field);

            field = new EntityField();
            field.Name = "Description";
            field.IsRequired = true;
            field.MaxSize = 500;
            field.Type = new Loki.DataRepresentation.IntrinsicEntities.String();
            category.Fields.Add(field);
            category.IsAbstract = true;
            category.Persistable = true;
            category.Visibility = "protected";

            EntityMethod init = new EntityMethod();
            init.Name = "Init";

            category.Methods.Add(init);

            Model list = new Model();
            list.Add(category);
            classes.Model = list;
        }
Ejemplo n.º 5
0
        public override void Init( IProject project, IDependencyManager dependencies, IBuildAggregator aggregator )
        {
            base.Init( project, dependencies, aggregator );

            EntityClass channel = new EntityClass("Channel", "public");
            EntityClass participants = new EntityClass("ChannelParticipant", "public");
            EntityClass entry = new EntityClass("ChannelEntry", "public");

            BuildChannel(channel);
            BuildParticipants(participants);
            BuildEntry(entry);

            BuildChannelParticipantConnection(channel, participants);
            BuildChannelEntryConnection(channel, entry);

            Project.Model.Add(channel);
            Project.Model.Add(participants);
            Project.Model.Add(entry);

            Directory.CreateDirectory(GetControlsOutputDir("Generic/LiveChat/"));
            GetRelativeOutputDir("",GetControlsOutputDir("WebControls/"));
            GetRelativeOutputDir("",GetControlsOutputDir("WebServices"));
            GetRelativeOutputDir("",GetControlsOutputDir("WebServices/LiveChat/"));
        }
Ejemplo n.º 6
0
        private void BuildChannelParticipantConnection(EntityClass channel, EntityClass participants)
        {
            EntityField channelParticipants = new EntityField("participants");
            channelParticipants.Type = participants;
            channelParticipants.Mult = Multiplicity.OneToMany;
            channel.Fields.Add(channelParticipants);

            EntityField participantChannel = new EntityField("Channel");
            participantChannel.Type = channel;
            participantChannel.Mult = Multiplicity.ManyToOne;
            participants.Fields.Add(participantChannel);
        }
Ejemplo n.º 7
0
        private void BuildChannelEntryConnection(EntityClass channel, EntityClass entry)
        {
            EntityField channelEntries = new EntityField("entries");
            channelEntries.Type = channel;
            channelEntries.Mult = Multiplicity.OneToMany;
            channel.Fields.Add(channelEntries);

            EntityField entryChannel = new EntityField("Channel");
            entryChannel.Type = channel;
            entryChannel.Mult = Multiplicity.ManyToOne;
            entry.Fields.Add(entryChannel);
        }
Ejemplo n.º 8
0
        private List<EntityField> GetFields( EntityClass e )
        {
            List<EntityField> fields = new List<EntityField>();

            do {
                foreach( EntityField field in e.Fields ) {
                    if( !e.RootEntity && field.Name == "id" ) {
                        continue;
                    }
                    fields.Add( field );
                }

                e = (EntityClass) e.Parent;
            } while( e != null );

            return fields;
        }
Ejemplo n.º 9
0
        private void TemplateClassTests(string output, EntityClass entity)
        {
            Dictionary<string, object> param = new Dictionary<string, object>();
            RelationDependencyFactory depFactory = new RelationDependencyFactory();
            RelationDependency dep = depFactory.create(entity, Project.Model);
            param.Add("entity", entity);
            param.Add("namespace", Project.Name + "." + ComponentType.Tests.ToString());
            param.Add("entityClass", (EntityClass)entity);
            param.Add( "coreName", Project.Name.ToString() + "." + ComponentType.Core.ToString() );
            param.Add( "dataName", Project.Name.ToString()  + "." + ComponentType.DataAccessLayer.ToString() );
            param.Add("dep", dep);
            param.Add("depsWhithDeclaration", DependenciesString(dep));
            param.Add("depsWhithoutDeclaration", DependenciesWhithoutDeclarationString(dep));

            string template = GetResource("BaseClassTestsTemplate.vtl");
            Templates.Generate(template, output, param);
        }
Ejemplo n.º 10
0
 private void CheckParent( EntityClass entity )
 {
     foreach( EntityField field in entity.Fields ) {
         field.Parent = entity;
     }
 }
Ejemplo n.º 11
0
        private static void BuildSmsTestModel()
        {
            EntityField field = null;

            /** User **/
            EntityClass user = new EntityClass();
            user.Name = "Principal";
            user.Visibility = "public";

            field = new EntityField();
            field.Name = "Id";
            field.IsPrimaryKey = true;
            field.Type = new Int();
            user.Fields.Add(field);

            /** IDescription Definition **/
            EntityInterface iDescription = new EntityInterface();
            iDescription.Name = "IDescription";
            iDescription.Visibility = "public";
            EntityMethod getDescription = new EntityMethod();
            getDescription.Name = "GetDescription";
            EntityParameter param = new EntityParameter();
            param.IsReturn = true;
            param.Type = IntrinsicTypes.Create( "System.String" );
            getDescription.ReturnEntity = param;
            iDescription.Methods.Add(getDescription);

            /** Category Definition **/

            EntityClass category = new EntityClass();
            category.Name = "Category";
            category.Visibility = "public";
            //category.Interfaces.Add(iDescription);

            field = new EntityField();
            field.Name = "Id";
            field.IsPrimaryKey = true;
            field.Type = new Int();
            category.Fields.Add(field);

            field = new EntityField();
            field.Name = "Description";
            field.IsRequired = true;
            field.MaxSize = 500;
            field.Type = new Loki.DataRepresentation.IntrinsicEntities.String();
            category.Fields.Add(field);

            /** Sms Definition **/

            EntityClass message = new EntityClass();
            message.Name = "SmsBase";
            message.IsAbstract = true;
            message.Visibility = "public";
            //message.Interfaces.Add(iDescription);

            field = new EntityField();
            field.Name = "Id";
            field.IsPrimaryKey = true;
            field.Type = new Int();
            message.Fields.Add(field);

            field = new EntityField();
            field.Name = "Description";
            field.IsRequired = true;
            field.MaxSize = 500;
            field.Default = "No Description";
            field.Type = new Loki.DataRepresentation.IntrinsicEntities.String();
            message.Fields.Add(field);

            field = new EntityField();
            field.Name = "Category";
            field.Type = category;
            field.Mult = Multiplicity.ManyToOne;
            field.IsRequired = true;
            message.Fields.Add(field);

            field = new EntityField();
            field.Name = "Principal";
            field.Type = user;
            field.Mult = Multiplicity.ManyToOne;
            field.IsRequired = true;
            message.Fields.Add(field);

            field = new EntityField();
            field.Name = "Messages";
            field.Type = message;
            field.Mult = Multiplicity.OneToMany;
            field.InfoOnly = true;
            user.Fields.Add(field);

            field = new EntityField();
            field.Name = "Messages";
            field.Type = message;
            field.InfoOnly = true;
            field.Mult = Multiplicity.OneToMany;
            category.Fields.Add(field);

            /** ImageSms **/
            EntityClass imageSms = new EntityClass();
            imageSms.Name = "ImageSms";
            imageSms.Visibility = "public";
            imageSms.Parent = message;

            field = new EntityField();
            field.Name = "ImageUrl";
            field.Type = new Loki.DataRepresentation.IntrinsicEntities.String();
            field.IsRequired = true;
            field.Default = "#";
            imageSms.Fields.Add(field);

            /** TextSms **/
            EntityClass textSms = new EntityClass();
            textSms.Name = "TextSms";
            textSms.Visibility = "public";
            textSms.Parent = message;

            field = new EntityField();
            field.Name = "Text";
            field.Type = new Loki.DataRepresentation.IntrinsicEntities.String();
            field.IsRequired = true;
            field.Default = "Empty";
            textSms.Fields.Add(field);

            /** Setting up project **/
            Model list = new Model();
            list.Add(category);
            list.Add(iDescription);
            list.Add(user);
            list.Add(message);
            list.Add(imageSms);
            list.Add(textSms);
            smsTestModel.Model = list;
        }
Ejemplo n.º 12
0
 private void WriteInformation(StreamWriter writer, List<EntityField> foreigns, EntityClass home)
 {
     foreach (EntityField field in foreigns) {
         writer.Write("\t\t<iforeign-key foreignTable=\"{0}\" ", field.Type.Name);
         writer.Write("name=\"{0}{1}\" ", home.Name, field.Type.Name);
         writer.WriteLine("onDelete=\"cascade\">");
         writer.Write("\t\t\t<ireference local=\"{0}\" ",field.Name);
         writer.WriteLine("foreign=\"Id\" />");
         writer.WriteLine("\t\t</iforeign-key>");
     }
 }
Ejemplo n.º 13
0
 private void WriteEntity(StreamWriter writer, EntityClass entity)
 {
     ClearInformation();
     writer.WriteLine("\t<table name=\"{0}\" javaName=\"{0}\">", entity.Name);
     foreach (EntityField field in entity.Fields) {
         if (!field.InfoOnly) {
             WriteEntityField(writer, field);
         }
     }
     WriteInformation(writer, foreign, entity);
     writer.WriteLine("\t</table>");
 }
Ejemplo n.º 14
0
        private void SetupConnection(EntityClass logger, EntityClass principal)
        {
            EntityField principalRef = new EntityField();
            principalRef.Name = "principal";
            principalRef.IsRequired = false;
            principalRef.Mult = Multiplicity.ManyToOne;
            principalRef.Type = principal;
            logger.Fields.Add(principalRef);

            EntityField loggerRef = new EntityField();
            loggerRef.Name = "Requests";
            loggerRef.Type = logger;
            loggerRef.Mult = Multiplicity.OneToMany;
            principal.Fields.Add(loggerRef);
        }
Ejemplo n.º 15
0
        private void BuildEntry(EntityClass entry)
        {
            EntityField id = new EntityField("id");
            id.IsPreview = true;
            id.IsRequired = true;
            id.Represents = true;
            id.IsPrimaryKey = true;
            id.Type = intEntity;
            entry.Fields.Add(id);

            EntityField text = new EntityField("text");
            text.IsPreview = false;
            text.Represents = false;
            text.Type = stringEntity;
            text.MaxSize = 3000;
            entry.Fields.Add(text);

            EntityField date = new EntityField("date");
            date.IsPreview = true;
            date.Type = dateTimeEntity;
            entry.Fields.Add(date);

            EntityClass principal = (EntityClass)Project.Model.GetByName("Principal");

            EntityField principalField = new EntityField("Principal");
            principalField.IsPreview = false;
            principalField.Represents = true;
            principalField.Type = principal;
            principalField.Mult = Multiplicity.ManyToOne;
            entry.Fields.Add(principalField);

            EntityField principalEntries = new EntityField("ChannelEntries");
            principalEntries.Type = entry;
            principalEntries.Mult = Multiplicity.OneToMany;
            principal.Fields.Add(principalEntries);
        }
Ejemplo n.º 16
0
        private void TemplateClassMethods(string output, EntityClass entity)
        {
            Dictionary<string, object> param = new Dictionary<string, object>();
            param.Add("entity", entity);
            param.Add("entityClass", (EntityClass)entity);
            param.Add("namespace", Project.Name + "." + ComponentType.Core.ToString());

            string template = GetResource("BaseClassMethodsTemplate.vtl");
            Templates.Generate(template, output, param);
        }
Ejemplo n.º 17
0
        private void BuildParticipants(EntityClass participants)
        {
            EntityField participantsId = new EntityField("id");
            participantsId.IsPreview = true;
            participantsId.IsRequired = true;
            participantsId.IsPrimaryKey = true;
            participantsId.Represents = true;
            participantsId.Type = intEntity;
            participants.Fields.Add(participantsId);

            EntityClass principal = (EntityClass)Project.Model.GetByName("Principal");

            EntityField principalRef = new EntityField("principal");
            principalRef.Mult = Multiplicity.ManyToOne;
            principalRef.Type = principal;
            participants.Fields.Add(principalRef);

            EntityField participantRef = new EntityField("Participants");
            participantRef.Mult = Multiplicity.OneToMany;
            participantRef.Type = participants;
            principal.Fields.Add(participantRef);
        }
Ejemplo n.º 18
0
        private EntityClass CreateEntityClass( XmlNode element )
        {
            EntityClass entity = new EntityClass();
            entity.Project = Project;

            if( element.Attributes["xmi:id"] != null ) {
                entity.Id = element.Attributes["xmi:id"].Value;
            }

            if( element.Attributes["name"] != null ) {
                entity.Name = element.Attributes["name"].Value;
            }

            if( element.Attributes["visibility"] != null ) {
                entity.Visibility = element.Attributes["visibility"].Value;
            }

            if( element.Attributes["isAbstract"] != null ) {
                entity.IsAbstract = XmiLoader.ParseBool( element.Attributes["isAbstract"] );
            }

            return entity;
        }
Ejemplo n.º 19
0
        private void BuildChannel(EntityClass channel)
        {
            EntityField channelId = new EntityField("id");
            channelId.IsRequired = true;
            channelId.IsPrimaryKey = true;
            channelId.IsPreview = true;
            channelId.Type = intEntity;
            channel.Fields.Add(channelId);

            EntityField channelName = new EntityField("name");
            channelName.IsPreview = true;
            channelName.IsRequired = true;
            channelName.Represents = true;
            channelName.Type = stringEntity;
            channel.Fields.Add(channelName);
        }
Ejemplo n.º 20
0
 public EntityClassResolver( EntityClass entity )
     : base(entity)
 {
 }