From afc7a07d285e08d905c58dd5978441c155b2f296 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 19 Dec 2017 10:25:40 +0200 Subject: MERGE. --- .../Templates/EntityCodeFileJava.cshtml | 59 ++++++++++++++++++++++ .../Templates/EnumerationFileJava.cshtml | 23 +++++++++ .../Templates/ObservablesAdapterFile.cshtml | 46 +++++++++++++++++ .../Templates/TangoDAOJavaFile.cshtml | 27 ++++++++++ 4 files changed, 155 insertions(+) create mode 100644 Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml create mode 100644 Software/Visual_Studio/Tango.CodeGeneration/Templates/EnumerationFileJava.cshtml create mode 100644 Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesAdapterFile.cshtml create mode 100644 Software/Visual_Studio/Tango.CodeGeneration/Templates/TangoDAOJavaFile.cshtml (limited to 'Software/Visual_Studio/Tango.CodeGeneration/Templates') diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml new file mode 100644 index 000000000..aeba15b12 --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJava.cshtml @@ -0,0 +1,59 @@ +package com.twine.tango.dal.entities; + +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; + + + @@Table(name = "@(Model.TableName)", database = TangoDB.class) + public class @(Model.Name) extends Entity + { + @foreach (var prop in Model.Fields) + { + if (!prop.Construct) + { +
+ @@Column(name = "@(prop.FieldName)") + private @(prop.Type) @(prop.Description); + +
+ } + else + { +
+ @@ForeignKey(references = { @@ForeignKeyReference(columnName = "@(prop.FieldName)_GUID", foreignKeyColumnName = "GUID")}) + private @(prop.Type) @(prop.Description); + +
+ } + } + + @foreach (var prop in Model.Fields) + { +
+ /** + * Gets the @(prop.Name). + * + * return the @(prop.Name) + */ + public @(prop.Type) @(prop.Type == "Boolean" ? "is" + prop.Name : "get" + prop.Name)() + { + return @(prop.Description); + } + + /** + * Sets the @(prop.Name). + * + * @@param @(prop.Description) the @(prop.Name) + */ + public void set@(prop.Name)(@(prop.Type) @(prop.Description)) + { + this.@(prop.Description) = @(prop.Description); + } +
+ } + } diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EnumerationFileJava.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EnumerationFileJava.cshtml new file mode 100644 index 000000000..435608204 --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EnumerationFileJava.cshtml @@ -0,0 +1,23 @@ +package com.twine.tango.dal.enumerations; + +import com.twine.tango.core.DescriptionAnnotation; + +public enum @(Model.Name) +{ + @foreach (var prop in Model.Fields) + { +
+ @@DescriptionAnnotation(description = "@(prop.Description)") + @(prop.Name)(@(prop.Value)), + +
+ } + ; + + private int value; + + @(Model.Name)(int value) + { + this.value = value; + } +} diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesAdapterFile.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesAdapterFile.cshtml new file mode 100644 index 000000000..856b8ac42 --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesAdapterFile.cshtml @@ -0,0 +1,46 @@ +using System.Collections.ObjectModel; +using System.ComponentModel; + +namespace Tango.DAL.Observables +{ + public partial class @(Model.Name) + { + @foreach (var prop in Model.Properties) + { +
+ private @(prop.Type) _@(prop.Name.ToLower()); + /// + /// Gets or sets the @(prop.Name). + /// + public @(prop.Type) @(prop.Name) + { + get { return _@(prop.Name.ToLower()); } + set { _@(prop.Name.ToLower()) = value; RaisePropertyChanged(nameof(@(prop.Name))); } + } + + private ICollectionView _@(prop.Name.ToLower())ViewSource; + /// + /// Gets or sets the @(prop.Name) View Source. + /// + public ICollectionView @(prop.Name)ViewSource + { + get { return _@(prop.Name.ToLower())ViewSource; } + set { _@(prop.Name.ToLower())ViewSource = value; RaisePropertyChanged(nameof(@(prop.Name)ViewSource)); } + } +
+ } + + /// + /// Initialize collection sources. + /// + private void InitCollectionSources() + { + @foreach (var prop in Model.Properties) + { +
+ @(prop.Name)ViewSource = CreateCollectionView(@(prop.Name)); +
+ } + } + } +} diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/TangoDAOJavaFile.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/TangoDAOJavaFile.cshtml new file mode 100644 index 000000000..46bd6532c --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/TangoDAOJavaFile.cshtml @@ -0,0 +1,27 @@ +package com.twine.tango.dal.dao; + +import com.raizlabs.android.dbflow.sql.language.SQLite; +@foreach (var entity in Model.Entities) +{ +
import com.twine.tango.dal.entities.@(entity.Name);
+} +import java.util.List; + +public class TangoDAO +{ +@foreach (var entity in Model.Entities) +{ +
+ /** + * Gets all the @(entity.TableName) from database. + * + * @@return all @(entity.TableName) + */ + public static List<@(entity.Name)> getAll@(entity.TableName)() + { + return SQLite.select().from(@(entity.Name).class).queryList(); + } + +
+} +} -- cgit v1.3.1