====== Query Specialization ====== This class is used for calculate the specializations of a given query. ===== Class Attributes ===== public static long executionTime; public static boolean PROLOG_SELECTION; public static String prolog_encoding; public static String queryForProlog; public static String metaProlog; public static String commandQuery; public static String encodingGUI; ===== Class Constructor ===== No constructor for this class ===== Class Methods ===== ==== getQuerySpecializations ==== public static Query getQueryGeneralizations (Query query, java.util.ArrayList currentTCs, Schema currentSchema, int maximal) throws Exception Main method of this class, that given an incomplete query computes complete query specializations of that query given that currentTCs are true and schema constraints from currentSchema holds. Based on the constant PROLOG_SELECTION, Magik runs two different prolog engines. //Called by:// * it.unibz.inf.magik.core.TCQCReasoner * it.unibz.inf.magik.test.TestQuerySpecialization **Parameters:** * Query - query that we want to find their specialization versions * currentTCs - which data are complete, expressed in TC-statements * currentSchema - database schema (that contains finite domain constraints and foreign keys) * maximal - maximal number of atoms that Magik can add for calculating specialization queries **Returns:** * Returned specialization are maximal (in query containment sense) **Throws:** * Exception ---- ==== getQuerySpecializationsSWI ==== public static Query getQueryGeneralizationsSWI (Query query, java.util.ArrayList currentTCs, Schema currentSchema, int maximal) throws Exception Method that manage the query specializations algorithm for SWI Prolog **Parameters:** * Query - query that we want to find their specialization versions * currentTCs - which data are complete, expressed in TC-statements * currentSchema - database schema (that contains finite domain constraints and foreign keys) * maximal - maximal number of atoms that Magik can add for calculating specialization queries **Returns:** * Returned specialization are maximal (in query containment sense) **Throws:** * Exception ---- ==== getQuerySpecializationsTuProlog ==== public static Query getQueryGeneralizationsTuProlog (Query query, java.util.ArrayList currentTCs, Schema currentSchema, int maximal) throws Exception Method that manage the query specializations algorithm for Tu Prolog **Parameters:** * Query - query that we want to find their specialization versions * currentTCs - which data are complete, expressed in TC-statements * currentSchema - database schema (that contains finite domain constraints and foreign keys) * maximal - maximal number of atoms that Magik can add for calculating specialization queries **Returns:** * Returned specialization are maximal (in query containment sense) **Throws:** * Exception ---- ==== generateInput ==== public static java.lang.String generateInput (java.util.ArrayList currentTCs, Schema schema, int maxQSpecSize) Method that encodes in Prolog currentSchema and TC-statements **Parameters:** * currentTCs - which data are complete, expressed in TC-statements * schema - database schema (that contains finite domain constraints and foreign keys) * maxQSpecSize - maximal number of atoms that Magik can add for calculating specialization queries **Returns:** * String that contains all the prolog code for the given schema and tc-statements ---- ==== generateInput ==== public static java.lang.String generateInput (java.util.ArrayList currentTCs, Schema schema, int maxQSpecSize) Method that encodes in Prolog currentSchema and TC-statements **Parameters:** * currentTCs - which data are complete, expressed in TC-statements * schema - database schema (that contains finite domain constraints and foreign keys) * maxQSpecSize - maximal number of atoms that Magik can add for calculating specialization queries **Returns:** * String that contains all the prolog code for the given schema and tc-statements ---- === generatePrologEnfFKs === public static java.util.ArrayList generatePrologEnfFKs (java.util.ArrayList fks) Method that encodes in Prolog Foreign Keys enforced ---- === generatePrologRels === public static java.util.ArrayList generatePrologRels (Schema schema) Method that encodes in Prolog relations of the schema selected ---- === generatePrologTCs === public static java.util.ArrayList generatePrologEnfTCs (java.util.ArrayList tcs) Method that encodes in Prolog TC-Statements ---- === generatePrologFDCs === public static java.util.ArrayList generatePrologFDCs (java.util.ArrayList fdcs) Method that encodes in Prolog finite domain constraints. For each FDC we call generatePrologFDC. ---- === generatePrologFDC === public static java.lang.String generatePrologFDCs (FiniteDomainContraint fdc) Method that encodes in Prolog a finite domain constraint. -------- === createInputFile === private static java.lang.String createInputFile (java.util.ArrayList prologFKsNotEnf, java.util.ArrayList prologFKsEnf, java.util.ArrayList prologRels, java.util.ArrayList prologPKs, java.util.ArrayList prologTCs, java.lang.String prologFDCs, java.lang.String prologQuery) Method that creates the final Prolog string for the schema, query and tc-statements. -------- === createInputGUI === private static java.lang.String createInputGUI (java.util.ArrayList prologFKsNotEnf, java.util.ArrayList prologFKsEnf, java.util.ArrayList prologRels, java.util.ArrayList prologPKs, java.util.ArrayList prologTCs, java.lang.String prologFDCs) Method that creates the final Prolog string for the schema and tc-statements that MAGIK will visualize in the GUI. ---- ==== readMeta ==== public static java.util.ArrayList generatePrologNotEnfFKs (java.util.ArrayList fks) Method that reads the file with the program that runs the input generated (used in GUI) ---- ==== generateQuery ==== public static java.lang.String generateQuery (Query query) Method that generate a part of the command used for call specialization algorithm ---- ==== generateCommand ==== public static java.lang.String generateCommand (java.lang.String q4p, int maximal) Method that generate the command used for call specialization algorithm ---- ==== parseQuerySpecializationsTUProlog ==== public static java.util.ArrayList parseQuerySpecializationsTuProlog (Query query, Schema schema, SolveInfo info) throws ContextException, NoSolutionException Method that analyses the solutions given by Prolog and returns the list of the specialization (if there are) ---- ==== getters and setters methods ==== public static java.lang.String getProlog_enconding() public static void setProlog_enconding (java.lang.String prolog_enconding) public static java.lang.String getQueryForProlog() public static void setQueryForProlog(java.lang.String queryForProlog) public static java.lang.String getMetaProlog() public static void setMetaProlog(java.lang.String metaProlog) public static java.lang.String getCommandQuery() public static void setCommandQuery(java.lang.String commandQuery) public static long getExecutionTime() public static void setExecutionTime(long executionTime) public static java.lang.String getEncodingGUI() public static void setEncodingGUI(java.lang.String encodingGUI)