Table of Contents

Query

public class Query
implements Serializable

This class describes a query that can be logically seen as a conjunction of relations (with equalities between attributes but without comparisons)

Class Attributes

private long id
private java.lang.String name
private java.util.ArrayList<Atom> atoms
private java.util.ArrayList<Term> outputVariables
private java.lang.String description
private java.lang.String sql
private boolean sematincs
private java.util.LinkedHashMap relationsMap
private boolean countExists

Class Constructors

Query

public Query ()

Default constructor

Called by:


Query

public Query (java.lang.String name, 
              java.util.ArrayList<Atom> atoms,
	      java.util.ArrayList<Term> outputVariables, 
              java.lang.String description) 

Constructor for creating a query with the most important fields not empty.

Called by:

Parameters:


Query

public Query (java.lang.String name, 
              java.lang.String SQLString, 
              java.lang.String description, 
              Schema schema) 
       throws ParseSQLQueryException, 
              ContextException

Constructor for creating a query by parsing SQL string.

Called by:

Parameters:

Throws:

Class Methods

applyCondition

private void applyCondition (java.lang.String termOld, 
                             java.lang.String termNew, 
                             java.util.HashMap<java.lang.String, java.lang.String> termEquality) 
                      throws ParseSQLQueryException 

Apply one or more conditions to a query

Parameters:

Throws:


checkSQLGroupBy

private boolean checkSQLGroupBy (java.lang.String SQLString, 
                                 java.lang.String attrSelect, 
                                 java.util.HashMap<java.lang.String, java.lang.String> relations) 
                          throws ParseSQLQueryException

Check the GROUP BY clause

Parameters:

Throws:


convertToSQLQuery

public void convertToSQLQuery (Schema s)

Convert a query into SQL code

Parameters:


getAttributesByRelationName

public java.lang.String getAttributesByRelationName (java.lang.String relName, 
                                                     java.lang.String alias, 
                                                     Schema schema) 
                                             throws ParseSQLQueryException

Find whether the relation name can be found in the schema

Parameters:

Returns:

Throws:


getAttributesByRelationName

private int getAttrPos (java.util.ArrayList<List<java.lang.String>> queryTerms, 
                        java.lang.String attr)

Used by convertToSQLQuery for searching inside the ArrayList of list of queryTerms the position of an attribute

Parameters:

Returns:


getRelation

private Relation getRelation (java.lang.String relation, 
                              java.util.ArrayList<Relation> relations)

Used in convertToSQLQuery for finding the relation from the set of relations

Parameters:

Returns:


getRelation

public boolean isAtomsContainingTerms()

Check whether list of atoms contain list of terms in output variables

Returns:


MinimizeQuery

public Query MinimizeQuery()

method for calling the query minimalization

Returns:


parseAtomStrings

public java.util.ArrayList<String> parseAtomStrings(java.util.HashMap<java.lang.String, java.lang.String> relations) {

Parse the string of relations to create list of atoms (still in string format)

Parameters:

Returns:


parseConditions

public void parseConditions (java.lang.String conditions, 
                             java.util.HashMap<java.lang.String, java.lang.String> relations) 
                      throws ParseSQLQueryException

Parse conditions from the WHERE clause

Parameters:

Throws:


parseOutputVariables

public java.lang.String parseOutputVariables(java.lang.String outputVars, 
                                             java.util.HashMap<java.lang.String, java.lang.String> relations) 
                                      throws ParseSQLQueryException

Parse the string of output variables in the case of output variable contains alias name (e.g. p1.name changed into P1_name)

Parameters:

Returns:


parseRelations

public java.util.LinkedHashMap<java.lang.String, java.lang.String> parseRelations(java.lang.String relations, 
                                                                                  Schema schema) 
                                                                           throws ParseSQLQueryException

Parse the relations and their aliases (if any)

Parameters:

Returns:

Throws:


parseSQLCount

public boolean parseSQLCount (java.lang.String SQLSelect) 
                       throws ParseSQLQueryException

Parse the COUNT clause

Parameters:

Returns:

Throws:


parseSQLFrom

public java.lang.String parseSQLFrom(java.lang.String SQLString) 
                       throws ParseSQLQueryException

Parse the FROM clause of an SQL query

Parameters:

Returns:

Throws:


parseSQLQuery

public void parseSQLQuery (java.lang.String SQLString, 
                           Schema schema) 
                    throws ParseSQLQueryException, 
                           ContextException

Parse the SQL statement of the query to set the output variables and list of atoms

Parameters:

Throws:


parseSQLSelect

public java.lang.String parseSQLSelect(java.lang.String SQLString) 
                                throws ParseSQLQueryException

Parse the SELECT clause of an SQL query

Parameters:

Returns:

Throws:



parseSQLWhere

public java.lang.String parseSQLWhere(java.lang.String SQLString) 
                               throws ParseSQLQueryException

Parse the WHERE clause of an SQL query

Parameters:

Returns:

Throws:


parseTermName

public java.lang.String parseTermName(java.lang.String sTerm, 
                                      java.util.HashMap<java.lang.String, java.lang.String> relations) 
                               throws ParseSQLQueryException

Change the term name (e.g., p1.nameP1_name)

Parameters:

Returns:

Throws:


printArrAtom

public java.lang.String printArrAtom()

Print array of atoms of the query

Returns:


printArrTerm

public java.lang.String printArrTerm()

Print array of terns of the query

Returns:


printHTML

public java.lang.String printHTML()

Print the query in a most compact way

Returns:


printSQLHTML

public java.lang.String printSQLHTML(boolean isVirtualSchema)

Print the query in a most compact way

Parameters:

Returns:


replaceTerm

public void replaceTerm (java.lang.String termOld, 
                         java.lang.String termNew) 
                  throws ParseSQLQueryException

Apply condition to list of atoms and also terms (output variables)

Parameters:

Throws:


getters and setters methods

public boolean getSemantics() 
public void setSemantics(boolean semantics) 
 
public java.lang.String getName() {
public void setName(java.lang.String name) 
 
public java.util.ArrayList<Atom> getAtoms() 
public void setAtoms(java.util.ArrayList<Atom> atoms) 
 
public java.lang.String getDescription() 
public void setDescription(java.lang.String description) 
 
public java.util.ArrayList<Term> getOutputVariables() 
public void setOutputVariables(java.util.ArrayList<Term> outputVariables) 
 
public java.lang.String getSql() 
public void setSql(java.lang.String sql) 
 
public long getId()
public void setId(long id) 

Back to Top | Back to Home Page