Skip to content

Commit

Permalink
feat: report functionnality (not complete)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Dec 13, 2024
1 parent 000ed06 commit d12ef09
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fr.insee.arc.web.gui.report.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import fr.insee.arc.web.gui.report.service.ServiceViewReport;

@Controller
public class ControllerViewReport extends ServiceViewReport {

/**
* Action trigger by selecting a calendar in the GUI. Update the GUI
*
* @return success
*/
@RequestMapping("/secure/selectReport")
public String selectReportAction(Model model) {
return selectReport(model);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package fr.insee.arc.web.gui.report.dao;

import java.util.HashMap;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;

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.core.model.TraitementPhase;
import fr.insee.arc.utils.dao.SQL;
import fr.insee.arc.utils.database.Delimiters;
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;

@Component
public class GererReportDao extends VObjectHelperDao {

private static final Logger LOGGER = LogManager.getLogger(GererReportDao.class);

/**
* dao call to build norm vobject
*
* @param viewNorme
*/
public void initializeViewReport(VObject viewReport) {

ViewEnum dataModelReport = ViewEnum.MAPPING_ARC_REPORT_OK;

Map<String, String> defaultInputFields = new HashMap<>();

ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder();

query.build(SQL.SELECT, query.sqlListeOfColumnsFromModel(dataModelReport));
query.build(SQL.FROM, dataObjectService.getView(dataModelReport), SQL.AS, ViewEnum.ALIAS_A);
query.build(SQL.WHERE, SQL.NOT, SQL.EXISTS, "(");
query.build(SQL.SELECT, SQL.FROM, dataObjectService.getView(ViewEnum.PILOTAGE_FICHIER), SQL.AS, ViewEnum.ALIAS_B);
query.build(SQL.WHERE, ColumnEnum.PHASE_TRAITEMENT, "=", query.quoteText(TraitementPhase.RECEPTION.toString()));
query.build(SQL.AND, ViewEnum.ALIAS_B, ".", ColumnEnum.O_CONTAINER, "=", ViewEnum.ALIAS_A, ".", ColumnEnum.ENTREPOT, "||", query.quoteText(Delimiters.SQL_TOKEN_DELIMITER), "||", ViewEnum.ALIAS_A, ".", ColumnEnum.ARCHIVE_FILENAME);
query.build(")");
query.build(SQL.ORDER_BY, ColumnEnum.ARCHIVE_TIMESTAMP, SQL.DESC);

// Initialize the vobject
vObjectService.initialize(viewReport, query, dataObjectService.getView(dataModelReport), defaultInputFields);
}

public VObjectService getvObjectService() {
return vObjectService;
}

public void setvObjectService(VObjectService vObjectService) {
this.vObjectService = vObjectService;
}

public DataObjectService getDataObjectService() {
return dataObjectService;
}

public void setDataObjectService(DataObjectService dataObjectService) {
this.dataObjectService = dataObjectService;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fr.insee.arc.web.gui.report.model;

import org.springframework.stereotype.Component;

import fr.insee.arc.web.gui.all.model.ArcModel;
import fr.insee.arc.web.gui.all.util.VObject;

@Component
public class ModelReport implements ArcModel {

// The report view
private VObject viewReport;


public ModelReport() {
this.viewReport = new ViewReport();
}


public VObject getViewReport() {
return viewReport;
}


public void setViewReport(VObject viewReport) {
this.viewReport = viewReport;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package fr.insee.arc.web.gui.report.model;

import java.util.HashMap;

import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder;
import fr.insee.arc.web.gui.all.util.ConstantVObject;
import fr.insee.arc.web.gui.all.util.VObject;
import fr.insee.arc.web.gui.all.util.ConstantVObject.ColumnRendering;

public class ViewReport extends VObject {
public ViewReport() {
super();

this.setTitle("view.report");

this.setDefaultPaginationSize(15);

this.setSessionName("viewReport");

this.setConstantVObject(new ConstantVObject(

new HashMap<String, ColumnRendering>() {
/**
*
*/
private static final long serialVersionUID = 4705381559117478720L;

{
put("id", new ColumnRendering(false, "label.id", "0%", "text", null, false));
}
}));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This package contains the controllers, service and data objects for the "debugging query sender" gui screen
*/
package fr.insee.arc.web.gui.report;
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package fr.insee.arc.web.gui.report.service;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;

import fr.insee.arc.utils.utils.LoggerHelper;
import fr.insee.arc.web.gui.all.service.ArcWebGenericService;
import fr.insee.arc.web.gui.all.util.VObject;
import fr.insee.arc.web.gui.report.dao.GererReportDao;
import fr.insee.arc.web.gui.report.model.ModelReport;

@Service
@Scope(scopeName = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class InteractorReport extends ArcWebGenericService<ModelReport, GererReportDao> {

protected static final String RESULT_SUCCESS = "jsp/gererReport.jsp";

private static final Logger LOGGER = LogManager.getLogger(InteractorReport.class);

@Autowired
protected ModelReport views;

// The action Name
public static final String ACTION_NAME="reportManagement";

@Override
public void putAllVObjects(ModelReport model) {

views.setViewReport(vObjectService.preInitialize(model.getViewReport()));

putVObject(views.getViewReport(), t -> initializeViewReport(t));
}

@Override
public String getActionName() {
return ACTION_NAME;
}


/**
* Initialize the {@value InteractorReport#viewNorme}. Call dao to create the view
*/
public void initializeViewReport(VObject viewReport) {
LoggerHelper.debug(LOGGER, "/* initializeNorme */");
dao.initializeViewReport(viewReport);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package fr.insee.arc.web.gui.report.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

@Service
public class ServiceViewReport extends InteractorReport {

/**
* Action trigger by selecting a calendar in the GUI. Update the GUI
*
* @return success
*/
public String selectReport(Model model) {
return basicAction(model, RESULT_SUCCESS);
}

public String sortReport(Model model) {
return sortVobject(model, RESULT_SUCCESS, this.views.getViewReport());
}

}
56 changes: 56 additions & 0 deletions arc-web/src/main/webapp/WEB-INF/jsp/gererReport.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib prefix="c" uri="jakarta.tags.core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="${pageContext.response.locale}">
<head>
<link rel="icon" href="data:,"/>
<title><spring:message code="header.reportManagement"/></title>
<c:import url="tiles/defaulthead.jsp">
<c:param name="pageJs" value="/js/gererNorme.js" />
</c:import>
</head>

<body class="bg-body">

<form
spellcheck="false"
id="selectReport"
action="selectReport.action"
method="post"
accept-charset="UTF-8"
>

<c:import url="tiles/header.jsp">
<c:param name="currentPage" value="reportManagement" />
</c:import>

<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<!-- norm list -->
<c:set var="view" value="${viewReport}" scope="request"/>
<c:import url="tiles/templateVObject.jsp">
<c:param name="btnSelect" value ="true" />
<c:param name="btnSee" value ="true" />
<c:param name="btnSort" value ="true" />
<c:param name="btnAdd" value ="false" />
<c:param name="btnUpdate" value ="false" />
<c:param name="btnDelete" value ="false" />
<c:param name="ligneAdd" value ="false" />
<c:param name="ligneFilter" value ="true" />
<c:param name="checkbox" value ="true" />
<c:param name="checkboxVisible" value ="true" />
<c:param name="extraScopeAdd" value ="" />
<c:param name="extraScopeDelete" value ="" />
<c:param name="extraScopeUpdate" value ="" />
<c:param name="extraScopeSee" value ="" />
</c:import>

</div>
</div>
</div>
</form>

</body>
</html>
1 change: 1 addition & 0 deletions arc-web/src/main/webapp/WEB-INF/jsp/tiles/header.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

<c:import url="tiles/template_header_link.jsp"><c:param name="linkRef" value="enterPilotageBAS" /><c:param name="linkId" value="envManagement" /></c:import>
<c:import url="tiles/template_header_link.jsp"><c:param name="linkRef" value="selectExport" /><c:param name="linkId" value="export" /></c:import>
<c:import url="tiles/template_header_link.jsp"><c:param name="linkRef" value="selectReport" /><c:param name="linkId" value="reportManagement" /></c:import>

<li><h5 class="mt-4">Maintenance</h5></li>
<c:import url="tiles/template_header_link.jsp"><c:param name="linkRef" value="selectParameters" /><c:param name="linkId" value="parameters" /></c:import>
Expand Down

0 comments on commit d12ef09

Please sign in to comment.