Class LinkedSQLWrapper

All Implemented Interfaces:
IPersistence, ISQLWrapper, AbstractDataObject, ICBLBeanNGroup, ICBLContainer, IFieldContainer, ISMBean, ISMDataType
Direct Known Subclasses:
DBMSWrapper, DMSWrapper, IDS2Wrapper, ImsDbSegment

public abstract class LinkedSQLWrapper extends SQLWrapper
Used for Hierarchical tables definitions such as IMS and DMS E.g. say we have COMPANY<-DEPARTMENT<-EMPLOYEE Where a COMPANY has many departments, who has many EMPLOYEES
These classes can be linked together, so when we open the first one, the remainder are opened at the right location.
  • Field Details

    • latestConditionType

      protected int latestConditionType
      Condition type is one of : IPersistence.CONDITION_TYPE_NO_CONDITION = 0; IPersistence.CONDITION_TYPE_EQUALS = 1; IPersistence.CONDITION_TYPE_GREATER = 2; IPersistence.CONDITION_TYPE_LESS = 3; IPersistence.CONDITION_TYPE_GREATER_OR_EQUALS = 4; IPersistence.CONDITION_TYPE_LESS_OR_EQUALS = 5;
    • masterKeys

      protected ISMObject[] masterKeys
    • childTables

      protected List<LinkedSQLWrapper> childTables
    • masterTables

      protected List<LinkedSQLWrapper> masterTables
    • KEYTYPE_IMPLICIT_ON_MASTER_AND_DETAIL

      public static final int KEYTYPE_IMPLICIT_ON_MASTER_AND_DETAIL
      BULL ids uses this strategy. It means MASTER table has a hidden key, and the foreign-key definition on DETAIL table uses a (hidden) reference to this key
      See Also:
    • KEYTYPE_EXPLICIT_ON_MASTER_ONLY

      public static final int KEYTYPE_EXPLICIT_ON_MASTER_ONLY
      not used Used for when foreign keys are defined "IMPLICITLY" ... We have not seen any dialects of Cobol which implements this strategy, however, we built the link-tables this way ... so lets keep the functionality and see whether any dialect uses this. PS ... for testing purposes, please see com.softwaremining.tests.linkedtables
      See Also:
    • KEYTYPE_EXPLICIT_ON_MASTER_AND_DETAIL

      public static final int KEYTYPE_EXPLICIT_ON_MASTER_AND_DETAIL
      not used Used for when foreign keys are defined "EXPLICITLY" ... The first version of IDS processing was (incorrectly) using this strategy We have not seen any dialects of Cobol which implements this strategy, however, we built the link-tables this way ... so lets keep the functionality and see whether any dialect uses this. PS ... for testing purposes, please see com.softwaremining.tests.linkedtables
      See Also:
    • keyExcplicity

      public int keyExcplicity
    • usesExplicitForeignkeyOnMaster

      protected boolean usesExplicitForeignkeyOnMaster
      Used for when foreign keys are defined "IMPLICITLY" ... We have not seen any dialects of Cobol which implements this strategy, however, we built the link-tables this way ... so lets keep the functionality PS ... for testing purposes, please see com.softwaremining.tests.linkedtables
    • nativeAndImplicitMasterKeys

      protected ISMObject[] nativeAndImplicitMasterKeys
      Used for when foreign keys are defined "IMPLICITLY" ... We have not seen any dialects of Cobol which implements this strategy, however, we built the link-tables this way ... so lets keep the functionality PS ... for testing purposes, please see com.softwaremining.tests.linkedtables
    • foreignKeys

      protected ISMObject[] foreignKeys
      this is an additional key as defined by the system, used as Foreign key by the associated
  • Constructor Details

    • LinkedSQLWrapper

      public LinkedSQLWrapper(BaseService owner)
      default constructor
      Parameters:
      owner -
  • Method Details

    • linkChild

      public void linkChild(LinkedSQLWrapper childTable)
    • setKeyExcplicity

      public void setKeyExcplicity(int keyExcplicity)
    • addMasterTable

      public void addMasterTable(LinkedSQLWrapper masterTable)
    • retrieveMasterTables

      public List<LinkedSQLWrapper> retrieveMasterTables()
      A-(parent-to)->B-(parent-to)->C
      then C.retrieveMasterTables will return "B"
    • retrieveAllMasterTables

      public List<LinkedSQLWrapper> retrieveAllMasterTables()
      A-(parent-to)->B-(parent-to)->C
      then C.retrieveAllMasterTables will return "A and B"
    • resetForeignKeys

      public void resetForeignKeys()
    • retrieveForeignKeys

      protected ISMObject[] retrieveForeignKeys()
      Description copied from class: SQLWrapper
      Stub method to be over-written by LinkedSQLWrapper class.
      Overrides:
      retrieveForeignKeys in class SQLWrapper
      Returns:
    • assignAccessMode

      public void assignAccessMode(int accessMode)
      Similar to the COBOL ACCESS Mode
      Specified by:
      assignAccessMode in interface ISQLWrapper
      Overrides:
      assignAccessMode in class AbstractIndexedFile
      Parameters:
      accessMode - : types are defined in IPersistence.ACCESS_MODE_xxx : Sequential, Random or Dynamic
    • setToOpen

      protected int setToOpen(int openMode) throws IOCriticalException
      open clas, and dependent / linked classes
      Throws:
      IOCriticalException
    • open

      public int open(int openMode) throws IOCriticalException
      open clas, and dependent / linked classes
      Overrides:
      open in class AbstractIndexedFile
      Throws:
      IOCriticalException
    • deleteRecord

      public int deleteRecord() throws IOStatusException
      Description copied from class: AbstractBasePersistence
      when operation is Unsuccessful throw Exception (e.g KeyNotFountException). See com.softwaremining.wrappers.exceptions
      Overrides:
      deleteRecord in class AbstractIndexedFile
      Returns:
      when successful it returns IPersistence.STATUS_SUCCESS
      Throws:
      IOStatusException
    • updateRecord

      public int updateRecord() throws IOStatusException
      Description copied from class: AbstractIndexedFile
      Translation of COBOL REWRITE statement
      Overrides:
      updateRecord in class AbstractIndexedFile
      Returns:
      when successful it returns IPersistence.STATUS_SUCCESS
      Throws:
      IOStatusException
    • insert

      public int insert()
      Description copied from class: AbstractIndexedFile
      Insert a record - populate the values from the existing fields
      Specified by:
      insert in interface ISQLWrapper
      Overrides:
      insert in class AbstractIndexedFile
    • nextRecord

      public int nextRecord() throws IOStatusException
      go to next
      Overrides:
      nextRecord in class AbstractIndexedFile
      Returns:
      IPersistence.STATUS_SUCCESS if records are found, Otherwise returns other values from IPersistence;
      Throws:
      IOStatusException
    • last

      public int last() throws IOStatusException
      Throws:
      IOStatusException
    • lastRecord

      public int lastRecord() throws IOStatusException
      Throws:
      IOStatusException
    • prevRecord

      public int prevRecord() throws IOStatusException
      go to next
      Overrides:
      prevRecord in class AbstractIndexedFile
      Returns:
      IPersistence.STATUS_SUCCESS if records are found, Otherwise returns other values from IPersistence;
      Throws:
      IOStatusException
    • readRecord

      public int readRecord() throws IOStatusException
      go to next
      Overrides:
      readRecord in class AbstractIndexedFile
      Returns:
      IPersistence.STATUS_SUCCESS if records are found, Otherwise returns other values from IPersistence;
      Throws:
      IOStatusException
    • seek

      public int seek(ISMObject key, int conditionType)
      Go to the record identified by key Condition type is one of : IPersistence.CONDITION_TYPE_NO_CONDITION = 0; IPersistence.CONDITION_TYPE_EQUALS = 1; IPersistence.CONDITION_TYPE_GREATER = 2; IPersistence.CONDITION_TYPE_LESS = 3; IPersistence.CONDITION_TYPE_GREATER_OR_EQUALS = 4; IPersistence.CONDITION_TYPE_LESS_OR_EQUALS = 5;
      Overrides:
      seek in class AbstractIndexedFile
    • seek

      public int seek(ISMObject[] keys, int conditionType)
      Go to the record identified by key Condition type is one of : IPersistence.CONDITION_TYPE_NO_CONDITION = 0; IPersistence.CONDITION_TYPE_EQUALS = 1; IPersistence.CONDITION_TYPE_GREATER = 2; IPersistence.CONDITION_TYPE_LESS = 3; IPersistence.CONDITION_TYPE_GREATER_OR_EQUALS = 4; IPersistence.CONDITION_TYPE_LESS_OR_EQUALS = 5;
      Overrides:
      seek in class AbstractIndexedFile
    • seek

      public int seek(ISMObject[] keys, int conditionType, boolean _masterSeekingChildren)
      Go to the record identified by key Condition type is one of : IPersistence.CONDITION_TYPE_NO_CONDITION = 0; IPersistence.CONDITION_TYPE_EQUALS = 1; IPersistence.CONDITION_TYPE_GREATER = 2; IPersistence.CONDITION_TYPE_LESS = 3; IPersistence.CONDITION_TYPE_GREATER_OR_EQUALS = 4; IPersistence.CONDITION_TYPE_LESS_OR_EQUALS = 5;
    • seekChildren

      protected void seekChildren(ISMObject[] keys, int conditionType) throws IOStatusException
      equivalant of START record in COBOL
      Parameters:
      key -
      conditionType -
      Throws:
      IOStatusException
    • assignForeignKeyValues

      public void assignForeignKeyValues(ISMObject[] keys, int conditionType)
    • close

      public int close()
      Description copied from class: AbstractBasePersistence
      Close the file
      Specified by:
      close in interface ISQLWrapper
      Overrides:
      close in class AbstractIndexedFile
      Returns:
      when successful it returns IPersistence.STATUS_SUCCESS
    • initializeParentAndChild

      public void initializeParentAndChild()
    • assignRecordKey

      public void assignRecordKey(AbstractCBLField recordKey)
    • addRecordKeyField

      public void addRecordKeyField(AbstractCBLField indexField)
      Parameters:
      indexField -
    • removeRecordKeys

      public void removeRecordKeys()
    • addRecordKeyField

      public void addRecordKeyField(CBLGroup indexGroup)
      Parameters:
      indexField -
    • getDeclaredRecordKeys

      public ISMObject[] getDeclaredRecordKeys()
    • retrieveNativeKeys

      public ISMObject[] retrieveNativeKeys()
      Native Keys refer to either a. any keys set by setRecordKey b. in absence of any keys defined by setRecordKey, then an additional index keys is created by SoftwareMining framework. This is usually called INDX_FLD_0;
      Specified by:
      retrieveNativeKeys in interface ISQLWrapper
      Overrides:
      retrieveNativeKeys in class SQLWrapper
      Returns:
    • assignForeignKeyReference

      public void assignForeignKeyReference(String fKTableName, AbstractCBLField fkField)
      This says Child has a key to Master which will act as foreign Index. E.g. Master has field ID , CHild has field: Master_ID where Child.Master_id = Master_id
      Parameters:
      fKTableName -
      fkField -
    • findOwner

      public void findOwner(LinkedSQLWrapper master)
    • useOidTableForKeyGeneration

      public boolean useOidTableForKeyGeneration()
      Stub method to be over-written by LinkedSQLWrapper class.
      Specified by:
      useOidTableForKeyGeneration in interface ISQLWrapper
      Overrides:
      useOidTableForKeyGeneration in class SQLWrapper
      Returns:
    • retrieveChildTables

      public List<LinkedSQLWrapper> retrieveChildTables()
    • isReadyForNextIMSRead

      public boolean isReadyForNextIMSRead()
    • assignReadyForNextIMSRead

      public void assignReadyForNextIMSRead(boolean readyForNextIMSRead)
    • isAllowSearchForChildern

      public boolean isAllowSearchForChildern()
    • assignAllowSearchForChildern

      public void assignAllowSearchForChildern(boolean allowSearchForChildern)