{{:magik-demo:magik_logo.png?nolink&500|}} ====== MAGIK Business Logic ====== This image is the Business Logic that stays backward MAGIK. {{ :magik-demo:developer:bl2.png?nolink&800 |}} For a detailed information and GUI implementation of the pages, please follow the link underlying: * [[magik-demo:developer:magik-business-logic#schema/index.jsp | schema/index.jsp]] * [[magik-demo:developer:magik-business-logic#schema/edit.jsp | schema/edit.jsp]] * [[magik-demo:developer:magik-business-logic#schema/editRelation.jsp | schema/editRelation.jsp]] * [[magik-demo:developer:magik-business-logic#schema/editConnection.jsp | schema/editConnection.jsp]] * [[magik-demo:developer:magik-business-logic#constraints/index.jsp | constraints/index.jsp ]] * [[magik-demo:developer:magik-business-logic#constraints/editFK.jsp | constraints/editFK.jsp ]] * [[magik-demo:developer:magik-business-logic#constraints/editFDC.jsp | constraints/editFDC.jsp]] * [[magik-demo:developer:magik-business-logic#constraints/editTC.jsp | constraints/editTC.jsp ]] * [[magik-demo:developer:magik-business-logic#constraints/editQuery.jsp | constraints/editQuery.jsp]] ===== schema/index.jsp ===== {{ :magik-demo:developer:schemaindex.png?nolink&700 |}} The schema page contains the list of schemas of which the current active user has. There are two categories of schemas: * **Server schemas** → the user create these schemas (or import from sample schema), thus the user may "//Select//", "//View//", "//Edit//" or "//Delete//" the schemas. * **Remote schemas** → the user load existing schemas from remote databases, thus the only action provided is to "//Select//", "//View//" or "//Delete//" the connection to it. The following are the details of each possible action in this page: - If the user click on "**Back**", it will be directed to the [[#index.jsp|welcome page]]. - If the user click on "****" or {{:magik-demo:developer:view.png?nolink&20|}} button, it will be directed to the same page (''schema/index.jsp'') that includes a new part of page ''schema/viewRelation.jsp'' in which user can **view relations** of the selected database: {{ :magik-demo:developer:viewrelation.png?nolink&600 |}} - If the user click on {{:magik-demo:developer:delete.png?nolink|}} button, the related database will be **removed** from the list and, only in case of virtual schema, it will be dropped. - If the user click on {{:magik-demo:developer:edit.png?nolink|}} button, user can **modify relations** of the selected database. This can be done in [[#schema/edit.jsp|relation page]] (''schema/edit.jsp'') - If the user click on **Import 'school' schema**, the school schema will be loaded inside the virtual schemas list - If the user click on **Add new schema**, it will be directed to the [[#schema/edit.jsp|relation page]] (''schema/edit.jsp'') in order to add a new virtual schema - If the user click on **Establish new remote connection**, it will be directed to the [[#schema/editConnection.jsp|database connection page]] (''schema/editConnection.jsp'') in order to establish a remote connection to real database - If the user click on **Connect to Database**, it will be directed to the [[#constraints/index.jsp|constraints page]] (''constraints/index.jsp'') in order to select the schema that we want to analyze [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== schema/edit.jsp ===== This page is used for 2 main operations: - **Create** a new virtual schema - **Edit** a virtual schema ==== Create a new virtual schema ==== {{ :magik-demo:developer:schemaempty.png?nolink&500 |}} - First of all user has to set the **Schema name** - After that user has to insert the relations. This can be done by press the **Add new relation** button that direct the user to the [[#schema/editRelation.jsp|edit relation page]] (''schema/editRelation.jsp''). - At the end of the insertion the user has to click **"Save"** in order to save new virtual schema - If the user press **"Cancel"** he will be directed to [[#schema/editRelation.jsp|edit relation page]] (''schema/editRelation.jsp'') ==== Edit a virtual schema ==== {{ :magik-demo:developer:showrelation.png?nolink&600 |}} The following are the details of each possible action in this page: - If the user click on **"Cancel"**, it will be directed to the [[#schema/index.jsp|schema page]]. - If the user click on **"Add new relation"**, it will be directed to the [[#schema/editRelation.jsp|edit relation page]] (''schema/editRelation.jsp'') with parameter ''?action=addrel''. - If the user click on {{:magik-demo:developer:delete.png?nolink|}} button, the selected relation will be **dropped** from the schema - If the user click on {{:magik-demo:developer:edit.png?nolink|}} button, it will be directed to the [[#schema/editRelation.jsp|edit relation page]] (''schema/editRelation.jsp'') in order to **modify** the selected relation - If the user click on **"Save"**, the current structure of the schema will be saved - If the user press **"Cancel"** he will be directed to [[#schema/editRelation.jsp|edit relation page]] (''schema/editRelation.jsp'') [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== schema/editRelation.jsp ===== This page is used for 2 different operations: - **Create** a new relation - **Edit** a relation {{ :magik-demo:developer:editrelationfilled.png?nolink&700 |}} The following are the details of each possible action in this page: - In order to **create a new relation**, user has to set //Relation Name//, //Keys// and //Attribute Names// and after that press **"Save"** - If the user press **"Cancel"**, the relation will be not created and it will be directed to [[#schema/index.jsp|schema selection page]] (''schema/index.jsp'') - If the user click on **"Save"**, all the modifications done will be stored and it will be directed to the [[#schema/edit.jsp|relation page]] (''schema/edit.jsp'') [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== schema/editConnection.jsp ===== This page is used for **Create** a new connection to a remote database If a user want to create a new connection to a remote database it has to fill this page. {{ :magik-demo:developer:dbconn.png?nolink&680 |}} - If the user press **Connect** the information inside the form will be saved and, if correct, the new connection can be available in [[#schema/edit.jsp|schema page]] with also a notice of this insertion. - If the user press **Cancel** the information inside the form will be discard and it will be directed to [[#schema/edit.jsp|schema page]]. ===== constraints/index.jsp ===== This page is the most important of all the system, because from here you can ask to MAGIK if a query is complete or not. Recall that we have two different modality for databases: - **Server** mode: in this modality we have only the structure of database - **Remote** mode: in this modality we have a real structure (with foreign and primary keys constraints and also finite domain constraints that has to be always verified) and also real data. For these reasons, this page has different features, depending on the database modality. {{ :magik-demo:developer:indexconstraintsvirtual.png?nolink&700 |}} This page is a composition of jsp pages: * **showFK.jsp**: this jsp page is used for managing foreign keys (FK) of the schema. Main action available: - **Add new FK** by pressing the {{:magik-demo:developer:create.png?nolink&20|}} button. The user will be directed to [[#constraints/editFK.jsp|edit FK page]] (''constraints/editFK.jsp'') - **Edit a FK** by pressing the {{:magik-demo:developer:edit.png?nolink&20|}} button related to the FK that we want to edit - **Delete a FK** by pressing the {{:magik-demo:developer:delete.png?nolink&20|}} button related to the FK that we want to delete All the features are available only in **VIRTUAL** mode * **showFDC.jsp**: this jsp page is used for managing finite domain constraints (FDC) of the schema. Main action available: - **Add new FDC** by pressing the {{:magik-demo:developer:create.png?nolink&20|}} button. The user will be directed to [[#constraints/editFDC.jsp|edit FDC page]] (''constraints/editFDC.jsp'') - **Edit a FDC** by pressing the {{:magik-demo:developer:edit.png?nolink&20|}} button related to the FDC that we want to edit - **Delete a FDC** by pressing the {{:magik-demo:developer:delete.png?nolink&20|}} button related to the FDC that we want to delete All the features are available only in **VIRTUAL** mode * **showTC.jsp**: this jsp page is used for managing table completeness statements (TC) of the schema. Main action available: - **Add new TC** by pressing the {{:magik-demo:developer:create.png?nolink&20|}} button. The user will be directed to [[#constraints/editTC.jsp|edit TC page]] (''constraints/editTC.jsp'') - **Edit a TC** by pressing the {{:magik-demo:developer:edit.png?nolink&20|}} button related to the TC that we want to edit - **Delete a TC** by pressing the {{:magik-demo:developer:delete.png?nolink&20|}} button related to the TC that we want to delete * **showQuery.jsp**: this jsp page is used for managing queries of the schema. Main action available: - **Add new query** by pressing the {{:magik-demo:developer:create.png?nolink&20|}} button. The user will be directed to [[#constraints/editQuery.jsp|edit query page]] (''constraints/editQuery.jsp'') - **Edit a query** by pressing the {{:magik-demo:developer:edit.png?nolink&20|}} button related to the query that we want to edit - **Delete a query** by pressing the {{:magik-demo:developer:delete.png?nolink&20|}} button related to the query that we want to delete - **View** the selected query in the right side box Other action that can be done in index.jsp is: - **Return** to schema selection by pressing the "Back to schema selection" button. The user will be directed to the [[#schema/edit.jsp|schema page]]. - **Execute MAGIK** by pressing "Run" button. The user will be directed to the same page but with some modifications. ==== Run Query ==== MAGIK after its execution, will answer if the query is complete or not under the the constraints selected. * If the query is **complete** in //VIRTUAL// mode, it will be displayed in the bottom of the page the result: {{ :magik-demo:developer:completevirtual.png?nolink&600 |}} * If the query is **complete** in //REMOTE// mode, it will be displayed in the bottom of the page the result with, if there are, data related to the query {{ :magik-demo:developer:completeremote.png?nolink&600 |}} By pressing on **View data output comparison** MAGIK show how many entries are available for the query * If the query is **incomplete**, it will be displayed in the bottom of the page which table are incomplete and if there are, the most specific generalization (MSG) query and the least specific specialization queries (LSS) {{ :magik-demo:developer:notcompletereal.png?nolink&500 |}} In the page is also possible: * **Add TC-statements** suggested to the other of the schema. The user has just to select which ones he wants to add and press "Add selected TC-statement(s)" button * **Add approximize query** given by MAGIK to the other queries already inside the schema. The user has just to select which ones he wants to add and press "Add selected query(ies)" * **Recalculate MSG** in order to obtain, if it possible, more MSG queries that has depth at most the depth of the original query plus the number set in the textbox on the left side of the button * Also in //REMOTE// mode is possible to see how many entries there are for each query. Also is possible view the data output by clicking on **View data output comparison** {{ :magik-demo:developer:dataoutput.png?nolink&700 |}} [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== constraints/editFK.jsp ===== Page available only for **VIRTUAL** schemas {{ :magik-demo:developer:showfk.png?nolink&700 |}} This page can be reached in 2 different modalities: * **New** for the definition of a new foreign key * **Edit** for modifying foreign key already inserted The following are the details of each possible action in this page: - If the user click on **"Cancel"**, it will be directed to the [[#constraints/index.jsp|constraints page]] and all the modification will be discarded. - If the user click on **"Save"**, it will be directed to the [[#constraints/index.jsp|constraints page]] (''constraints/index.jsp'') and the new foreign key or the modification will be saved in the schema - If the user click on **"Show Relations"**, it will be seen the table that are inside the schema [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== constraints/editFDC.jsp ===== For **REMOTE** schemas, one needs to edit schema database schema using favorite database management program. For example, to create a finite domain constrain using ''ENUM'' construct in PostgresSQL database one can execute the following code: CREATE TYPE school.type as enum ('primary','middle'); In this way new data type is created. Then defining attribute name is some table to be of this type, create Finite Domain Constraint on that attribute. Page available only for **VIRTUAL** schemas {{ :magik-demo:developer:showfdc.png?nolink&650 |}} This page can be reached in 2 different modalities: * **New** for the definition of a new finite domain constraint * **Edit** for modifying finite domain constraint already inserted The following are the details of each possible action in this page: - If the user click on **"Cancel"**, it will be directed to the [[#constraints/index.jsp|constraints page]] and all the modification will be discarded. - If the user click on **"Save"**, it will be directed to the [[#constraints/index.jsp|constraints page]] (''constraints/index.jsp'') and the new finite domain constraints or the modification will be saved in the schema - If the user click on **"Show Relations"**, it will be seen the table that are inside the schema [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== constraints/editTC.jsp ===== {{ :magik-demo:developer:showTC.png?nolink&700 |}} This page can be reached in 2 different modalities: * **New** for the definition of a table completeness statement * **Edit** for modifying table completeness statement already inserted The following are the details of each possible action in this page: - If the user click on **"Cancel"**, it will be directed to the [[#constraints/index.jsp|constraints page]] and all the modification will be discarded. - If the user click on **"Save"**, it will be directed to the [[#constraints/index.jsp|constraints page]] (''constraints/index.jsp'') and the new table completeness statement or the modification will be saved in the schema - If the user click on **"Show Relations"**, it will be seen the table that are inside the schema [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]] ===== constraints/editQuery.jsp ===== {{ :magik-demo:developer:showQuery.png?nolink&700 |}} This page can be reached in 2 different modalities: * **New** for the definition of a new query * **Edit** for modifying query already inserted The following are the details of each possible action in this page: - If the user click on **"Cancel"**, it will be directed to the [[#constraints/index.jsp|constraints page]] and all the modification will be discarded. - If the user click on **"Save"**, it will be directed to the [[#constraints/index.jsp|constraints page]] (''constraints/index.jsp'') and the new query or the modification will be saved in the schema - If the user click on **"Show Relations"**, it will be seen the table that are inside the schema [[magik-demo:developer:magik-business-logic|Back to Top]] | [[magik-demo:start|Back to Home Page]]