-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
203 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
arc-web/src/main/java/fr/insee/arc/web/gui/query/dao/QueryDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package fr.insee.arc.web.gui.query.dao; | ||
|
||
import java.util.HashMap; | ||
|
||
import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; | ||
import fr.insee.arc.core.dataobjects.ColumnEnum; | ||
import fr.insee.arc.core.dataobjects.DataObjectService; | ||
import fr.insee.arc.core.dataobjects.ViewEnum; | ||
import fr.insee.arc.utils.dao.SQL; | ||
import fr.insee.arc.utils.dao.UtilitaireDao; | ||
import fr.insee.arc.web.gui.all.util.VObject; | ||
import fr.insee.arc.web.gui.all.util.VObjectHelperDao; | ||
import fr.insee.arc.web.gui.all.util.VObjectService; | ||
|
||
public class QueryDao extends VObjectHelperDao { | ||
|
||
private VObjectService vObjectService; | ||
private DataObjectService dataObjectService; | ||
|
||
public QueryDao(VObjectService vObjectService, DataObjectService dataObjectService) { | ||
super(); | ||
this.vObjectService = vObjectService; | ||
this.dataObjectService = dataObjectService; | ||
} | ||
|
||
/** | ||
* dao call to build query vobject | ||
* | ||
* @param viewWsContext | ||
*/ | ||
public void initializeQuery(VObject viewQuery, String myQuery) { | ||
HashMap<String, String> defaultInputFields = new HashMap<>(); | ||
|
||
if (myQuery!=null){ | ||
String m=myQuery.trim(); | ||
if (m.endsWith(";")) | ||
{ | ||
m=m.substring(0, m.length()-1); | ||
} | ||
|
||
ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(m); | ||
|
||
if (Boolean.TRUE.equals(UtilitaireDao.get(0).testResultRequest(null, query))) | ||
{ | ||
this.vObjectService.initialize(viewQuery, query, "arc.ihm_query", defaultInputFields); | ||
} | ||
else | ||
{ | ||
try { | ||
UtilitaireDao.get(0).executeImmediate(null, myQuery); | ||
this.vObjectService.destroy(viewQuery); | ||
viewQuery.setMessage("query.complete"); | ||
} catch (Exception e) { | ||
this.vObjectService.destroy(viewQuery); | ||
viewQuery.setMessage(e.getMessage()); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
/** | ||
* dao call to build tables vobject | ||
* | ||
* @param viewWsContext | ||
*/ | ||
public void initializeTable(VObject viewTable, String mySchema) { | ||
ViewEnum dataModelTable = ViewEnum.PG_TABLES; | ||
String nameOfViewTable = dataObjectService.getView(dataModelTable); | ||
// view query | ||
ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); | ||
query.build(SQL.SELECT, ColumnEnum.TABLENAME, SQL.FROM, nameOfViewTable); | ||
query.build(SQL.WHERE, ColumnEnum.SCHEMANAME, "='" + mySchema + "'"); | ||
// default value | ||
HashMap<String, String> defaultInputFields = new HashMap<>(); | ||
// initialize vobject | ||
vObjectService.initialize(viewTable, query, "arc.ihm_table", defaultInputFields); | ||
} | ||
|
||
public static String queryTableSelected(String mySchema, String tableName) { | ||
return "select * from " + mySchema + "." + tableName + " limit 10 "; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
arc-web/src/main/java/fr/insee/arc/web/gui/webservice/dao/WebserviceDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package fr.insee.arc.web.gui.webservice.dao; | ||
|
||
import java.util.HashMap; | ||
|
||
import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; | ||
import fr.insee.arc.core.dataobjects.ColumnEnum; | ||
import fr.insee.arc.core.dataobjects.DataObjectService; | ||
import fr.insee.arc.core.dataobjects.ViewEnum; | ||
import fr.insee.arc.utils.dao.SQL; | ||
import fr.insee.arc.web.gui.all.util.VObject; | ||
import fr.insee.arc.web.gui.all.util.VObjectHelperDao; | ||
import fr.insee.arc.web.gui.all.util.VObjectService; | ||
|
||
public class WebserviceDao extends VObjectHelperDao { | ||
|
||
private VObjectService vObjectService; | ||
private DataObjectService dataObjectService; | ||
|
||
public WebserviceDao(VObjectService vObjectService, DataObjectService dataObjectService) { | ||
super(); | ||
this.vObjectService = vObjectService; | ||
this.dataObjectService = dataObjectService; | ||
} | ||
|
||
/** | ||
* dao call to build webservice vobject | ||
* | ||
* @param viewWsContext | ||
*/ | ||
public void initializeWebserviceContext(VObject viewWsContext) { | ||
ViewEnum dataModelWsContext = ViewEnum.IHM_WS_CONTEXT; | ||
String nameOfViewWsContext = dataObjectService.getView(dataModelWsContext); | ||
// view query | ||
ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); | ||
query.build(SQL.SELECT, "*", SQL.FROM, nameOfViewWsContext); | ||
// default value | ||
HashMap<String, String> defaultInputFields = new HashMap<>(); | ||
// initialize vobject | ||
vObjectService.initialize(viewWsContext, query, nameOfViewWsContext, defaultInputFields); | ||
} | ||
|
||
/** | ||
* dao call to build selected webservice vobject | ||
* | ||
* @param viewWsQuery | ||
*/ | ||
public void initializeWebserviceQuery(VObject viewWsQuery) { | ||
ViewEnum dataModelWsQuery = ViewEnum.IHM_WS_QUERY; | ||
String nameOfViewWsQuery = dataObjectService.getView(dataModelWsQuery); | ||
// view query | ||
ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); | ||
query.build(SQL.SELECT, "*", SQL.FROM, nameOfViewWsQuery); | ||
query.build(SQL.WHERE, sqlEqualWithFirstSelectedRecord(ColumnEnum.SERVICE_NAME), SQL.AND, sqlEqualWithFirstSelectedRecord(ColumnEnum.CALL_ID)); | ||
// default value | ||
HashMap<String, String> defaultInputFields = buildDefaultInputFieldsWithFirstSelectedRecord(ColumnEnum.SERVICE_NAME, ColumnEnum.CALL_ID); | ||
// initialize vobject | ||
vObjectService.initialize(viewWsQuery, query, nameOfViewWsQuery, defaultInputFields); | ||
} | ||
|
||
} |
Oops, something went wrong.