Class DATranscxt

java.lang.Object
io.odysz.transact.sql.Transcxt
io.odysz.semantic.DATranscxt
Direct Known Subclasses:
DBSyntableBuilder, DBSynTransBuilder

public class DATranscxt extends io.odysz.transact.sql.Transcxt
A Statement builder that can providing statements handling callback methods.

Those statements are the starting points to build a sql transact for querying, updating, etc.
For how to use the created statements, see the testing class: DASemantextTest.

This manager can handling semantics configured in xml. See loadSemanticsXml(String).
Every sql building needing semantics handling must use a context instance created by instancontxt(String, IUser).
Author:
odys-z@github.com
  • Field Details

    • cfgroot

      protected static String cfgroot
    • runtimepath

      protected static String runtimepath
    • dummy

      protected static io.odysz.semantics.IUser dummy
    • smtMaps

      protected static HashMap<String,DATranscxt.SemanticsMap> smtMaps
      { conn: map{table: DASemantics[handlers]} }
  • Constructor Details

    • DATranscxt

      public DATranscxt(String conn) throws Exception

      Create a transact builder with basic DASemantext instance.

      If it's a null configuration, the semantics can not be used to resulving semantics between records, but can be used to do basic sql operation. (resulving is a special concept of semantic-*, see docs)

      When creating DATranscxt, db metas can not be null.
      Parameters:
      conn - connection Id
      Throws:
      Exception
    • DATranscxt

      public DATranscxt() throws Exception
      Create a stub transaction helper without depending on a database connection, typically for initialization.
      Throws:
      Exception
      Since:
      2.0.0
    • DATranscxt

      protected DATranscxt(DASemantext stxt)
  • Method Details

    • configRoot

      public static void configRoot(String cfgRoot, String absRuntimeRoot)
      Configuration's root
      Parameters:
      cfgRoot -
      absRuntimeRoot - absolute path to current dir (test) or container root (web app)
      Since:
      1.4.25 will using EnvPath for this.
    • tableMeta

      public io.odysz.semantics.meta.TableMeta tableMeta(String conn, String tabl) throws SemanticException
      Overrides:
      tableMeta in class io.odysz.transact.sql.Transcxt
      Throws:
      SemanticException
    • instancontxt

      public io.odysz.semantics.ISemantext instancontxt(String connId, io.odysz.semantics.IUser usr) throws io.odysz.transact.x.TransException

      Create a new semantext instance with the static resources.

      DATranscxt use a basic context (without semantics handler) for basic sql building.
      Every context used for DASemantics handling must use this to create a new context instance.
      Overrides:
      instancontxt in class io.odysz.transact.sql.Transcxt
      Parameters:
      connId - connection id usually mapped with client function uri, like: Connects.uri2conn(req.uri())
      usr -
      Returns:
      semantext
      Throws:
      io.odysz.transact.x.TransException
      See Also:
      • ISemantext
    • select

      public io.odysz.transact.sql.Query select(String tabl, String... alias)
      Create a select statement.

      This statement is the starting points to build a sql transact for querying.
      For how to use the created statements, see the testing class: DASemantextTest.

      Overrides:
      select in class io.odysz.transact.sql.Transcxt
      See Also:
      • Transcxt.select(java.lang.String, java.lang.String[])
    • insert

      public io.odysz.transact.sql.Insert insert(String tabl, io.odysz.semantics.IUser usr)
      Create an insert statement that will report affected rows as data entry "total".

      Those statements are the starting points to build a sql transact for querying, updating, etc.
      For how to use the created statements, see the testing class: DASemantextTest.

      Parameters:
      tabl -
      usr -
      Returns:
      the starting statement
    • findResulved

      public static String findResulved(io.odysz.semantics.SemanticObject rslt, String tabl, String pk)
    • update

      public io.odysz.transact.sql.Update update(String tabl, io.odysz.semantics.IUser usr)
      Create an update statement that will report affected rows as data entry "total".

      Those statements are the starting points to build a sql transact for querying, updating, etc.
      For how to use the created statements, see the testing class: DASemantextTest.

      Parameters:
      tabl -
      usr -
      Returns:
      the starting statement
    • delete

      public io.odysz.transact.sql.Delete delete(String tabl, io.odysz.semantics.IUser usr)
      Create a delete statement that will report affected rows as data entry "total".

      Those statements are the starting points to build a sql transact for querying, updating, etc.
      For how to use the created statements, see the testing class: DASemantextTest.

      Parameters:
      tabl -
      usr -
      Returns:
      the starting statement
    • loadSemanticsXml

      public static XMLTable loadSemanticsXml(String connId) throws SAXException, IOException, SemanticException
      Load semantics configuration, x-table, from file path. This method also initialize table meta by calling Connects.
      Parameters:
      connId -
      Returns:
      configurations
      Throws:
      SAXException
      IOException
      SQLException
      SemanticException
    • initConfigs

      public static <M extends DATranscxt.SemanticsMap, S extends DASemantics> M initConfigs(String conn, XMLTable xcfg, DATranscxt.SmapFactory<M> smFactory) throws Exception
      Load smtMaps.
      Type Parameters:
      M - semantics map type
      S - semantics
      Parameters:
      conn -
      xcfg -
      smFactory -
      Returns:
      map per conn
      Throws:
      Exception
    • hasSemantics

      public static boolean hasSemantics(String conn, String tabl, DASemantics.smtype sm)
    • getHandler

      public static DASemantics.SemanticHandler getHandler(String conn, String tabl, DASemantics.smtype sm)
    • getBasicTrans

      public static io.odysz.transact.sql.Transcxt getBasicTrans(String conn) throws SQLException, SAXException, IOException, SemanticException
      Get a basic transact builder (without semantics handling)
      Parameters:
      conn -
      Returns:
      the basic transact builder
      Throws:
      SQLException
      IOException
      SAXException
      SemanticException
    • key

      public static void key(String name, String value)
      Set a key (configuration item).
      Parameters:
      name - e.g. connection's root-key is set here with name = "user-pswd".
      value -
    • key

      public static String key(String name)
      Load a configuration item.
      Parameters:
      name - configuration key, e.g. "user-pswd"
      Returns:
      the value
    • now

      public Date now(String conn) throws io.odysz.transact.x.TransException, SQLException
      Throws:
      io.odysz.transact.x.TransException
      SQLException
    • dummyUser

      public static io.odysz.semantics.IUser dummyUser()
    • exists

      public boolean exists(String conn, String tbl, String id) throws io.odysz.transact.x.TransException, SQLException
      Throws:
      io.odysz.transact.x.TransException
      SQLException
    • quotation

      public io.odysz.transact.sql.parts.AbsPart quotation(Object v, String conn, String tabl, String col)
      Overrides:
      quotation in class io.odysz.transact.sql.Transcxt