Symphony Framework
Symphony DataREST v3.2
Symphony Templates > Symphony DataREST v3.2
Template file name Symphony_DataREST_v3_2.tpl

The Symphony_DataREST (version 3.2) provides the ability to create a powerful repository based Symphony Data Object class that is fully compatible with the Symphony Bridge REST API.

The generated class utilizes the powerful BaseDataObject class within the Symphony.Conductor.Model namespace.  The generated class exposes the individual fields from the Synergy Repository as Native CLR types.  These properties convert the underlying Synergy data fields using the Symphony.Conductor.Converters classes.

 

Symphony Data Objects provide a number of powerful capabilities including:

The generated classes are designed to be used in Synergy .Net developments.  They are primarily designed to support exposing data through Symphony Bridge.
It is recommended that your generated code from the Symphony_DataREST template is created into a project sub-folder called Data.
 CodeGen Template Tokens
Token Comments
NAMESPACE Define the namespace within which the generated class will be placed (-n option).
 Symphony Tokens
             

There are no Symphony tokens applicable to this template.

           
 CodeGen Command Examples
Data object
codegen e -r -s PART -t Symphony_DataREST_v3_2 -o %ROOT%ControlLibrary\Data -n ControlLibrary.Data

 

 Example
;;****************************************************************************
;; WARNING: This code was code generated. Any changes that you
;;          make to this code will be overwritten if the code is regenerated!
;;
;; Template author: Richard C. Morris : RCP Consultants.
;;
;; Template Name:   Symphony Framework : SYMPHONY_DATAREST_V3_2.tpl
;;
;;***************************************************************************
import System
import System.Collections
import System.Collections.Generic
import System.Collections.ObjectModel
import System.Collections.Specialized
import System.Text
import System.Runtime.InteropServices
import System.IO

import Symphony.Conductor.Model
import Symphony.Conductor.Converters

import System.Reflection
import System.Runtime.Serialization
import Newtonsoft.Json


namespace ControlLibrary.Data

    ;;define a structure that we can use around the applicaiton
    {JsonObject(MemberSerialization.OptIn)}
    public partial class Part_DataREST extends DataObjectBase

        private mPart_main    ,strPart
        private mFieldList                ,string

        ;;use symphony converters
        private mDateConveter              ,@SynergyDecimalDateConverter ,new SynergyDecimalDateConverter()
        private mAlphaConveter             ,@SynergyAlphaConverter ,new SynergyAlphaConverter()
        private mDecimalConveter           ,@SynergyDecimalConverter ,new SynergyDecimalConverter()
        private mImpliedDecimalConveter    ,@SynergyImpliedDecimalConverter  ,new SynergyImpliedDecimalConverter()
        private mIntegerConveter           ,@SynergyIntConverter ,new SynergyIntConverter()
        private mAlphaYNConveter           ,@SynergyAlphaYNConverter, new SynergyAlphaYNConverter()

        ;;; <summary>
        ;;;  Constructor, initialise the base fields
        ;;; </summary>
        public method Part_DataREST
            endparams
            parent()
        proc
            mFieldList = string.Empty
            if (SynergyMemberInfo == ^null)
                DefineSerialiazableDataElements(^null)
        endmethod

        ;;; <summary>
        ;;;  Constructor, initialise the base fields
        ;;; </summary>
        public method Part_DataREST
            in req SynRec                        ,string
            endparams
            parent()
        proc
            mFieldList = string.Empty
            SynergyRecord = synRec
            if (SynergyMemberInfo == ^null)
                DefineSerialiazableDataElements(^null)
        endmethod

        ;;; <summary>
        ;;; Allow the Symphony Bridge server to inject the full data object
        ;;; </summary>
        ;;; <param name="inputObject"></param>
        public method PutServerObject    ,void
            in req inputObject            ,@Part_Data
            endparams
        proc
            this.SynergyRecord = inputObject.SynergyRecord
        endmethod

        ;;enable the ability to define which "properties" are serialized as JSON

        public static SynergyMemberInfo, @List<System.Reflection.MemberInfo>

        public method DefineSerialiazableDataElements    ,void
            in req fieldList                                    ,@List<string>
            endparams
        proc

            if (SynergyMemberInfo == ^null)
            then
                SynergyMemberInfo = new List<System.Reflection.MemberInfo>()
            else
                SynergyMemberInfo.Clear()

            data objectType = ^typeof(Part_DataREST)
            data item    ,string
            if (fieldList == ^null) then
            begin
                ;;this is required for select *
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Id"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Groupid"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Supplierid"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Description"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Technical_info"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Quantity"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Cost_price"), @System.Reflection.MemberInfo))
                SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, "Part_status"), @System.Reflection.MemberInfo))
            
            end
            else
            begin
                foreach item in fieldList
                begin
                    SynergyMemberInfo.Add(^as(RuntimeReflectionExtensions.GetRuntimeProperty(objectType, item(1:1) + item(2,item.Length).ToLower()), @System.Reflection.MemberInfo))
                end
            end

        endmethod

        ;;Expose fields as properties for data binding


        ;;Id
        {JsonProperty}
        public property Id, string
            method get
            proc
                mreturn (string)mAlphaConveter.Convert(mPart_main.str_id, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_id = (A)mAlphaConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Id"
                else
                    mFieldList = mFieldList + "," + "Id"
            endmethod
        endproperty

        ;;Groupid
        {JsonProperty}
        public property Groupid, string
            method get
            proc
                mreturn (string)mAlphaConveter.Convert(mPart_main.str_groupid, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_groupid = (A)mAlphaConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Groupid"
                else
                    mFieldList = mFieldList + "," + "Groupid"
            endmethod
        endproperty

        ;;Supplierid
        {JsonProperty}
        public property Supplierid, string
            method get
            proc
                mreturn (string)mAlphaConveter.Convert(mPart_main.str_supplierid, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_supplierid = (A)mAlphaConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Supplierid"
                else
                    mFieldList = mFieldList + "," + "Supplierid"
            endmethod
        endproperty

        ;;Description
        {JsonProperty}
        public property Description, string
            method get
            proc
                mreturn (string)mAlphaConveter.Convert(mPart_main.str_description, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_description = (A)mAlphaConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Description"
                else
                    mFieldList = mFieldList + "," + "Description"
            endmethod
        endproperty

        ;;Technical_info
        {JsonProperty}
        public property Technical_info, string
            method get
            proc
                mreturn (string)mAlphaConveter.Convert(mPart_main.str_technical_info, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_technical_info = (A)mAlphaConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Technical_info"
                else
                    mFieldList = mFieldList + "," + "Technical_info"
            endmethod
        endproperty

        ;;Quantity
        {JsonProperty}
        public property Quantity, int
            method get
            proc
                mreturn (int)mIntegerConveter.Convert(mPart_main.str_quantity, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_quantity = (I)mIntegerConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Quantity"
                else
                    mFieldList = mFieldList + "," + "Quantity"
            endmethod
        endproperty

        ;;Cost_price
        {JsonProperty}
        public property Cost_price, decimal
            method get
            proc
                mreturn (decimal)mImpliedDecimalConveter.Convert(mPart_main.str_cost_price, ^null, ^null, ^null)
            endmethod
            method set
            proc
                mPart_main.str_cost_price = (ID)mImpliedDecimalConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Cost_price"
                else
                    mFieldList = mFieldList + "," + "Cost_price"
            endmethod
        endproperty

        ;;Part_status
        {JsonProperty}
        public property Part_status, int
            method get
            proc
                mreturn Convert.ToInt64(mDecimalConveter.Convert(mPart_main.str_part_status, ^null, ^null, ^null))
            endmethod
            method set
            proc
                mPart_main.str_part_status = (D)mDecimalConveter.ConvertBack(value, ^null, ^null, ^null)
                if (mFieldList.Length == 0) then
                    mFieldList = mFieldList + "Part_status"
                else
                    mFieldList = mFieldList + "," + "Part_status"
            endmethod
        endproperty

        ;;; <summary>
        ;;; Expose the complete synergy record
        ;;; </summary>
        public override property SynergyRecord, String
            method get
            proc
                mreturn (string)mPart_main
            endmethod
            method set
            proc
                mPart_main = value
            endmethod
        endproperty

        public override method InitialValidateData, void
            endparams
        proc
        endmethod
    
        public override method SetFieldFocusFlag    ,void
        in req fieldName                        ,String
            endparams
        proc
        endmethod

        public override property StructureSize    ,Int32
            method get
            proc
                mreturn 700
            endmethod
        endproperty
            
        public property FieldList    ,string
            method get
            proc
                mreturn mFieldList
            endmethod
        endproperty
        
    endclass
endnamespace

See Also

Reference