User Tools

Site Tools


magik-demo:developer:class:core:programgenerator

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== Program Generator ====== ''**public class ProgramGenerator**'' This class generates EDB (Extensional Database) and translate the schema constraints into a DLV program ===== Class Attributes ===== No attributes for this class ===== Class Constructor ===== No constructor for this class ===== Class Methods ===== For better comprehension of the class, the figure underlying illustrates the dependencies between methods. {{ :magik-demo:developer:class:core:generateprogram.png?nolink&850 |}} ---- ==== generateProgram ==== <code java> public static java.util.ArrayList<java.lang.String> generateProgram (Query relQ, java.util.ArrayList <TCStatement> tcs, boolean semantics, Schema schema, boolean isThereComparisons ) throws CycleException, PrimaryKeyViolationException </code> This method managing all the process of generation of the DLV program. **Parameters:** * relQ - query that we want to analyze * tcs - TC-statements selected * semantics - //TRUE// if distinct-set semantics, //FALSE// if none-multiset semantics * isThereComparison **Returns:** * DLV program associated to the parameters given **Exceptions:** * CycleException * PrimaryKeyViolationException ---- ---- ---- ==== makeEDB ==== <code java> private static java.lang.String makeEDB (Query relQ, boolean isUnfolding) </code> An internal auxiliary function, needed for conversion of query to prototypical EDB. **Parameters:** * relQ - query that we want to analyze * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Returns:** * String with the extensional database definition ---- ==== makeP_TC ==== <code java> private static java.util.ArrayList<java.lang.String> makeP_TC (java.util.ArrayList <TCStatement> tcs, boolean isUnfolding) </code> Creates the line of the program related to a list of rules out of a set of TC statements **Parameters:** * relQ - query that we want to analyze * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Returns:** * List of line of program related to TC-Statements given ---- ==== makeQ_a ==== <code java> private static java.lang.String makeQ_a (Query Q, boolean semantics, boolean isUnfolding) </code> This method generates line of program for a given query **Parameters:** * Q - query that we want to generate the program * semantics - //TRUE// if distinct-set semantics, //FALSE// if none-multiset semantics * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Returns:** * line of program associated to the query ---- ==== makeFDC_Rules ==== <code java> private static java.util.ArrayList<java.lang.String> makeFDC_Rules ( java.util.ArrayList<FiniteDomainConstraint> fdcs) </code> This method generates the lines of program for all the finite domain constraints selected. **Parameter:** * fdcs - finite domain constraints to convert **Returns:** * list of lines of program for the finite domain constraints given ---- ==== createValFunctionalityContraint ==== <code java> private static java.lang.String createValFunctionalityContraint () </code> **Returns:** * String of val functionality ---- ==== generatePredicateOriginal ==== <code java> public static java.lang.String generatePredicateOriginal (Query query) </code> This method generates the lines of program for the original predicate. **Parameter:** * query - query that has to be converted **Returns:** * list of lines of program for the original predicate of the query ---- ---- ---- ==== makeEDB_Atom ==== <code java> static java.lang.String makeEDB_Atom (Atom atom, boolean isUnfolding) </code> An internal auxiliary function, needed for conversion of atoms of the query to prototypical EDB. **Parameters:** * atom - atom that we want to convert * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * String with the extensional database definition of the atom ---- ==== TCToString ==== <code java> private static java.lang.String TCToString (TCStatement tc, boolean isUnfolding) </code> An internal auxiliary function converts TCStatement into a string readable by DLV as a rule TC = (R(s),G) is converted into R_a(s) :- R(s), G; **Parameters:** * atom - atom that we want to convert * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * String with the TC-statement convert into line of code ---- ==== makeBodyAtom ==== <code java> static Atom makeBodyAtom (Atom atom, boolean semantics, boolean isUnfolding, java.util.ArrayList<Term> distinguished) </code> **Parameters:** * atom - atom * semantics - //TRUE// if distinct-set semantics, //FALSE// if none-multiset semantics * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding * distiguished - list of the terms distinguished **Return** * Atom with the distinguished terms ---- ==== make_a(Atom) ==== <code java> static Atom make_a (Atom atom) </code> This function takes an atom and return the same one but with _a prefix to the name **Parameters:** * atom - atom that we want to convert **Return** * atom with _a prefix to the name ---- ==== make_Q_a_vals ==== <code java> static java.lang.String make_Q_a_vals (Atom atom, Atom unfoldedAtom, boolean semantics, boolean isUnfolding, java.util.ArrayList<Term> distinguished) </code> **Parameters:** * atom - atom that we want to convert * unfoldedAtom - atom unfolded * semantics - //TRUE// if distinct-set semantics, //FALSE// if none-multiset semantics * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding * distiguished - list of terms distinguished **Return** * String with val in query Q_a ---- ==== makeSkolemRule ==== <code java> public static java.util.ArrayList<java.lang.String> makeSkolemRule (ForeignKey fk, boolean isUnfolding) </code> Apply Skolem rule to foreign key **Parameters:** * fk - foreign key * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * list of ... ---- ==== makeAuxRule ==== <code java> public static java.lang.String makeAuxRule (ForeignKey fk, boolean isUnfolding) </code> Create aux rule from a foreign key **Parameters:** * fk - foreign key to convert * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * Line of code for aux rule for foreign key ---- ==== makeEDB_Atom ==== <code java> public static java.lang.String makeCopyRule (ForeignKey fk, boolean isUnfolding) </code> Make the copy rule for a given foreign key **Parameters:** * fk - foreign key that needs the copy rule * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * Line of code for copy rule related to the foreign key ---- ---- ---- ==== unfoldTC_Atom ==== <code java> static java.lang.String unfoldTC_Atom (Atom atom, boolean isUnfolding) </code> Creates the line of code related to unfolded atom of the TC-statement **Parameters:** * atom - atom that we want to unfold * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * Line of code generated for the unfolded atom ---- ==== make_a (String) ==== <code java> static java.lang.String make_a (java.lang.String atom){ </code> This function takes an atom (in String format) and return the same one but with _a prefix to the name **Parameters:** * atom - atom that we want to convert **Return** * String of the atom with the _a prefix ---- ==== makeDoubleVal ==== <code java> static java.lang.String makeDoubleVal (Term a, Term b) </code> **Parameters:** * a - term * b - term **Return** * String ---- ==== makeVal ==== <code java> static java.lang.String makeVal (Term a, Term b) </code> Create the val line of code for two terms **Parameters:** * a - term * b - associated term to assign to term a **Return** * Val rule for the term a assigned the value of the term b ---- ==== makeEDB_Atom ==== <code java> static java.lang.String makeEDB_Atom (Atom atom, boolean isUnfolding) </code> An internal auxiliary function, needed for conversion of atoms of the query to prototypical EDB. **Parameters:** * atom - atom that we want to convert * isUnfolding - //TRUE// if unfolding needed, //FALSE// no unfolding **Return** * String with the extensional database definition of the atom ----

magik-demo/developer/class/core/programgenerator.1374827314.txt.gz · Last modified: 2017/07/06 15:24 (external edit)