diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-19 18:16:30 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-19 18:16:30 +0200 |
| commit | c16f47eb401a12f034eecf75924680262285e1f4 (patch) | |
| tree | f13693f0f5c58edd66211197b5ed360fdab32118 /Software/Visual_Studio | |
| parent | 96352ac46ccb871783c63fd98efe034091214b7e (diff) | |
| download | Tango-c16f47eb401a12f034eecf75924680262285e1f4.tar.gz Tango-c16f47eb401a12f034eecf75924680262285e1f4.zip | |
Working on android DAL.
Diffstat (limited to 'Software/Visual_Studio')
6 files changed, 71 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs index 194cd0fc1..0ff4f47d0 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs @@ -10,7 +10,7 @@ namespace Tango.CodeGeneration /// Represents a database entity Java code file. /// </summary> /// <seealso cref="Tango.CodeGeneration.Class" /> - public class EntityCodeFileJava : Class + public class EntityCodeFileJava : Class { /// <summary> /// Gets or sets the name of the entity. @@ -18,6 +18,11 @@ namespace Tango.CodeGeneration public String EntityName { get; set; } /// <summary> + /// Gets or sets the extends. + /// </summary> + public String Extends { get; set; } + + /// <summary> /// Gets or sets the name of the table. /// </summary> public String TableName { get; set; } diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJavaExtension.cs b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJavaExtension.cs new file mode 100644 index 000000000..99ea437a6 --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJavaExtension.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.CodeGeneration +{ + /// <summary> + /// Represents a database entity Java code file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.Class" /> + public class EntityCodeFileJavaExtension : Class + { + /// <summary> + /// Gets or sets the extends. + /// </summary> + public String Extends { get; set; } + + /// <summary> + /// Gets or sets the name of the table. + /// </summary> + public String TableName { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="EntityCodeFileJavaExtension"/> class. + /// </summary> + /// <param name="name">The name.</param> + public EntityCodeFileJavaExtension(String name, String extends) : base(name) + { + Extends = extends; + } + } +} diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj b/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj index 3c6c9d085..db77d9f20 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj +++ b/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj @@ -64,6 +64,7 @@ <Compile Include="CodeFile.cs" /> <Compile Include="CodeObject.cs" /> <Compile Include="DpProperty.cs" /> + <Compile Include="EntityCodeFileJavaExtension.cs" /> <Compile Include="EntityCodeFileJava.cs" /> <Compile Include="EntityCodeFile.cs" /> <Compile Include="EnumerationField.cs" /> @@ -111,6 +112,7 @@ <EmbeddedResource Include="Templates\ObservablesContextCodeFile.cshtml" /> <EmbeddedResource Include="Templates\ProtoMessageFile.cshtml" /> <EmbeddedResource Include="Templates\ProtoEnumFile.cshtml" /> + <EmbeddedResource Include="Templates\EntityCodeFileJavaExtension.cshtml" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml index 87c82395b..d9200a718 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml @@ -3,16 +3,13 @@ import com.raizlabs.android.dbflow.annotation.Column; import com.raizlabs.android.dbflow.annotation.ForeignKey; import com.raizlabs.android.dbflow.annotation.ForeignKeyReference; -import com.raizlabs.android.dbflow.annotation.Table; import org.joda.time.DateTime; import com.twine.tango.dal.Entity; -import com.twine.tango.dal.TangoDB; import android.databinding.Bindable; import com.twine.tango.dal.BR; - @@Table(name = "@(Model.TableName)", database = TangoDB.class) - public class @(Model.Name) extends Entity + public abstract class @(Model.Name) extends Entity { @foreach (var prop in Model.Fields) { diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJavaExtension.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJavaExtension.cshtml new file mode 100644 index 000000000..8498f3311 --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJavaExtension.cshtml @@ -0,0 +1,11 @@ +package com.twine.tango.dal.entities; + +import com.raizlabs.android.dbflow.annotation.Table; +import com.twine.tango.dal.TangoDB; + +@@Table(name = "@(Model.TableName)", database = TangoDB.class, cachingEnabled = true) +public class @(Model.Name) extends @(Model.Extends) +{ + + +} diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs index ba950f3db..75cfffe50 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs @@ -194,13 +194,16 @@ namespace Tango.DBObservablesGenerator.CLI //Generate Entities... foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) { - EntityCodeFileJava codeFile = new EntityCodeFileJava(DalNameToStandardName(table.Name).Singularize(false)) + EntityCodeFileJava codeFile = new EntityCodeFileJava(DalNameToStandardName(table.Name).Singularize(false) + "Base") { EntityName = table.Name.Singularize(false), TableName = table.Name, }; - + EntityCodeFileJavaExtension extensionCodeFile = new EntityCodeFileJavaExtension(DalNameToStandardName(table.Name).Singularize(false), codeFile.Name) + { + TableName = table.Name + }; foreach (var field in table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => !x.Name.Contains("GUID"))) { @@ -227,6 +230,9 @@ namespace Tango.DBObservablesGenerator.CLI { codeField.Type = DalNameToStandardName(field.PropertyType.Name).Singularize(false); codeField.Construct = true; + codeField.FieldName = codeField.FieldName.Singularize(false).ToUpper(); + codeField.Description = codeField.Description.Singularize(false); + codeField.Name = codeField.Type; } else if (field.PropertyType == typeof(Byte[]) || field.PropertyType == typeof(Boolean) || field.PropertyType == typeof(Double)) { @@ -242,11 +248,20 @@ namespace Tango.DBObservablesGenerator.CLI } codeFile.IndentResult = false; + extensionCodeFile.IndentResult = false; String code = codeFile.GenerateCode(); + String extensionCode = extensionCodeFile.GenerateCode(); String entitiesPath = Path.Combine(targetPath, "entities"); Directory.CreateDirectory(entitiesPath); File.WriteAllText(Path.Combine(entitiesPath, codeFile.Name + ".java"), code); + + String extensionCodeFilePath = Path.Combine(entitiesPath, extensionCodeFile.Name + ".java"); + + if (!File.Exists(extensionCodeFilePath)) + { + File.WriteAllText(extensionCodeFilePath, extensionCode); + } } //Generate Entities... |
