Class PsaRstApiObjBas

  • Direct Known Subclasses:
    PsaRstApiObj

    public class PsaRstApiObjBas
    extends java.lang.Object
    REST API: base implementation of a data object
    Since:
    22.01.2024
    Author:
    weiland
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_DATA
      The place holder data to indicate that the default value for a field should be used
    • Constructor Summary

      Constructors 
      Constructor Description
      PsaRstApiObjBas()
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkAccess​(de.pisa.psc.srv.dto.PscDto dto, int row)
      check if the session has read access on a record
      PsaRstApiEvtHdl getEventHandler()
      get the event handler
      protected de.pisa.psc.srv.dto.PscFld getField​(de.pisa.psc.srv.dto.PscDto dto, java.lang.String fld_dsc, java.lang.String lng)
      get the data object field
      PsaRstApiObjBas.IsoDate getIsoDate()
      get the ISO date controller class
      static java.util.Optional<PsaRstApiMapFld.MapEntry> getMappedClassField​(java.util.List<PsaRstApiMapFld.MapEntry> field_mapping, java.lang.String name)
      get the field mapping by search for a JSON field
      boolean getSetMaxData()
      get if the maximum number of characters should be set to a field
      boolean getSkipBaseFields()
      get if base fields should be skipped during the loading of data
      boolean getSkipIdField()
      if base fields are skipped get if the id field should be skipped too
      void loadData​(de.pisa.psc.srv.dto.PscDto dto, int row)
      fill the attributes with data from the data object
      protected void loadDataComponents​(de.pisa.psc.srv.dto.PscDto dto, int row)
      load the data for all attributes with a PsaRstApiMapCom annotation
      protected void loadDataFields​(de.pisa.psc.srv.dto.PscDto dto, int row)
      load the data for all attributes with a PsaRstApiMapFld annotation
      protected void loadDataRelations​(de.pisa.psc.srv.dto.PscDto dto, int row)
      load the data for all attributes with a PsaRstApiMapRel annotation
      protected DataMapping newDataMapping()
      get a new data mapping instance
      protected de.pisa.psc.srv.dto.PscDto newDto​(de.pisa.psc.srv.glb.PscSsn ssn, java.lang.String dsc)
      create a new data object
      protected PsaRstApiObjBas.StringMapper newStringMapper​(de.pisa.psc.srv.glb.PscSsn ssn)
      get a new string mapper
      void setData​(de.pisa.psc.srv.dto.PscDto dto, int row)
      set the value of the attributes at the data object
      void setDataPostPut​(de.pisa.psc.srv.dto.PscDto dto, int row)
      Hook after the data has been set and putDat has been called on the data object
      void setEventHandler​(PsaRstApiEvtHdl event_handler)
      set the event handler
      void setEventHandler​(PsaRstApiObjBas object)
      set the event handler to the same event handler of another object
      void setIsoDate​(PsaRstApiObjBas.IsoDate iso_date)
      set the ISO date controller class
      void setSetMaxData​(boolean max)
      set if the maximum number of characters should be set to a field
      void setSkipBaseFields​(boolean skip_base_fields)
      set if base fields should be skipped during the loading of data
      void setSkipIdField​(boolean skip_id_field)
      if base fields are skipped set if the id field should be skipped too
      protected boolean skipField​(java.lang.reflect.Field field)
      check if a class field should be skipped during loading the data
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_DATA

        public static final java.lang.String DEFAULT_DATA
        The place holder data to indicate that the default value for a field should be used
        See Also:
        Constant Field Values
    • Constructor Detail

      • PsaRstApiObjBas

        public PsaRstApiObjBas()
        Constructor
    • Method Detail

      • setSkipBaseFields

        public void setSkipBaseFields​(boolean skip_base_fields)
        set if base fields should be skipped during the loading of data
        Parameters:
        skip_base_fields - true to skip fields
      • getSkipBaseFields

        public boolean getSkipBaseFields()
        get if base fields should be skipped during the loading of data
        Returns:
        true to skip fields
      • setSkipIdField

        public void setSkipIdField​(boolean skip_id_field)
        if base fields are skipped set if the id field should be skipped too
        Parameters:
        skip_id_field - true to skip field (default=true)
      • getSkipIdField

        public boolean getSkipIdField()
        if base fields are skipped get if the id field should be skipped too
        Returns:
        true to skip fields
      • setSetMaxData

        public void setSetMaxData​(boolean max)
        set if the maximum number of characters should be set to a field
        Parameters:
        max - number of character
      • getSetMaxData

        public boolean getSetMaxData()
        get if the maximum number of characters should be set to a field
        Returns:
        number of character
      • setIsoDate

        public void setIsoDate​(PsaRstApiObjBas.IsoDate iso_date)
        set the ISO date controller class
        Parameters:
        iso_date - class
      • setEventHandler

        public void setEventHandler​(PsaRstApiEvtHdl event_handler)
        set the event handler
        Parameters:
        event_handler - handler
      • setEventHandler

        public void setEventHandler​(PsaRstApiObjBas object)
        set the event handler to the same event handler of another object
        Parameters:
        object - object to get the vent handler from
      • getEventHandler

        public PsaRstApiEvtHdl getEventHandler()
        get the event handler
        Returns:
        handler
      • newDto

        protected de.pisa.psc.srv.dto.PscDto newDto​(de.pisa.psc.srv.glb.PscSsn ssn,
                                                    java.lang.String dsc)
                                             throws java.lang.Exception
        create a new data object
        Parameters:
        ssn - session
        dsc - descriptor of the data object
        Returns:
        data object
        Throws:
        java.lang.Exception
      • newStringMapper

        protected PsaRstApiObjBas.StringMapper newStringMapper​(de.pisa.psc.srv.glb.PscSsn ssn)
                                                        throws java.lang.Exception
        get a new string mapper
        Parameters:
        ssn - session
        Returns:
        mapper
        Throws:
        java.lang.Exception
      • getMappedClassField

        public static java.util.Optional<PsaRstApiMapFld.MapEntry> getMappedClassField​(java.util.List<PsaRstApiMapFld.MapEntry> field_mapping,
                                                                                       java.lang.String name)
        get the field mapping by search for a JSON field
        Parameters:
        field_mapping - field mappings
        name - name of the JSON field to search
        Returns:
        mapping
      • checkAccess

        public boolean checkAccess​(de.pisa.psc.srv.dto.PscDto dto,
                                   int row)
                            throws java.lang.Exception
        check if the session has read access on a record
        Parameters:
        dto - dto
        row - row to check
        Returns:
        true if record can be read
        Throws:
        java.lang.Exception
      • loadData

        public void loadData​(de.pisa.psc.srv.dto.PscDto dto,
                             int row)
                      throws java.lang.Exception
        fill the attributes with data from the data object
        Parameters:
        dto - data object
        row - row
        Throws:
        java.lang.Exception
      • loadDataFields

        protected void loadDataFields​(de.pisa.psc.srv.dto.PscDto dto,
                                      int row)
                               throws java.lang.Exception
        load the data for all attributes with a PsaRstApiMapFld annotation
        Parameters:
        dto - data object
        row - row
        Throws:
        java.lang.Exception
      • loadDataComponents

        protected void loadDataComponents​(de.pisa.psc.srv.dto.PscDto dto,
                                          int row)
                                   throws java.lang.Exception
        load the data for all attributes with a PsaRstApiMapCom annotation
        Parameters:
        dto - data object
        row - row
        Throws:
        java.lang.Exception
      • loadDataRelations

        protected void loadDataRelations​(de.pisa.psc.srv.dto.PscDto dto,
                                         int row)
                                  throws java.lang.Exception
        load the data for all attributes with a PsaRstApiMapRel annotation
        Parameters:
        dto - data object
        row - row
        Throws:
        java.lang.Exception
      • setData

        public void setData​(de.pisa.psc.srv.dto.PscDto dto,
                            int row)
                     throws java.lang.Exception
        set the value of the attributes at the data object
        Parameters:
        dto - data object to modify
        row - row to modify
        Throws:
        java.lang.Exception
      • newDataMapping

        protected DataMapping newDataMapping()
                                      throws java.lang.Exception
        get a new data mapping instance
        Returns:
        mapper
        Throws:
        java.lang.Exception
      • setDataPostPut

        public void setDataPostPut​(de.pisa.psc.srv.dto.PscDto dto,
                                   int row)
                            throws java.lang.Exception
        Hook after the data has been set and putDat has been called on the data object
        Parameters:
        dto - data object
        row - the row that was modified
        Throws:
        java.lang.Exception
      • getField

        protected de.pisa.psc.srv.dto.PscFld getField​(de.pisa.psc.srv.dto.PscDto dto,
                                                      java.lang.String fld_dsc,
                                                      java.lang.String lng)
                                               throws de.pisa.psc.srv.glb.PscExc
        get the data object field
        Parameters:
        dto - data object
        fld_dsc - field descriptor
        lng - optional language identifier (e.g. GER or ENG)
        Returns:
        field
        Throws:
        de.pisa.psc.srv.glb.PscExc
      • skipField

        protected boolean skipField​(java.lang.reflect.Field field)
        check if a class field should be skipped during loading the data
        Parameters:
        field - field to check
        Returns:
        true if the field should be skipped