Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 998fb8ce authored by Guillaume Thomazon's avatar Guillaume Thomazon
Browse files

Add date rapid selection.

Add initialisation form url.
Add parameters in URL.
Add redirection when a parameter is change.

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@33942 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 444d3fcf
No related branches found
No related tags found
No related merge requests found
package net.ihe.gazelle.proxy.gui; package net.ihe.gazelle.proxy.gui;
import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
...@@ -168,6 +172,121 @@ public class MessagesBean { ...@@ -168,6 +172,121 @@ public class MessagesBean {
} }
} }
private String currentSelectDate;
public String getCurrentSelectDate() {
return currentSelectDate;
}
public void setCurrentSelectDate(String currentSelectDate) {
this.currentSelectDate = currentSelectDate;
}
public String selectDate(String date) {
if (!(date.equals("--")) && !(date.isEmpty()) && date != null) {
Date dateFrom, dateTo = null;
dateFrom = new Date();
Calendar cal = new GregorianCalendar();
if (date.equals("today")) {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
if (date.equals("yesterday")) {
if (cal.get(Calendar.DAY_OF_YEAR) == 1) {
cal.set(Calendar.YEAR, (cal.get(Calendar.YEAR) - 1));
cal.set(Calendar.MONTH, cal.get(Calendar.DECEMBER));
cal.set(Calendar.DAY_OF_MONTH, 31);
} else {
cal.set(Calendar.DAY_OF_YEAR, (cal.get(Calendar.DAY_OF_YEAR) - 1));
}
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
if (date.equals("this week")) {
if (cal.get(Calendar.DAY_OF_YEAR) < 7) {
cal.set(Calendar.YEAR, (cal.get(Calendar.YEAR) - 1));
cal.set(Calendar.MONTH, cal.get(Calendar.DECEMBER));
cal.set(Calendar.DAY_OF_MONTH, 31 - (7 - cal.get(Calendar.DAY_OF_YEAR)));
}
cal.set(Calendar.DAY_OF_WEEK, 2);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
if (date.equals("this month")) {
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
if (date.equals("last week")) {
if (cal.get(Calendar.WEEK_OF_YEAR) == 1) {
cal.set(Calendar.YEAR, (cal.get(Calendar.YEAR) - 1));
cal.set(Calendar.WEEK_OF_YEAR, 52);
} else {
cal.set(Calendar.WEEK_OF_YEAR, (cal.get(Calendar.WEEK_OF_YEAR) - 1));
}
cal.set(Calendar.DAY_OF_WEEK, 2);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
if (date.equals("last month")) {
if (cal.get(Calendar.MONTH) == 0) {
cal.set(Calendar.YEAR, (cal.get(Calendar.YEAR) - 1));
cal.set(Calendar.MONTH, cal.get(Calendar.DECEMBER));
} else {
cal.set(Calendar.MONTH, (cal.get(Calendar.MONTH) - 1));
}
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
if (date.equals("last hour")) {
cal.set(Calendar.HOUR, (cal.get(Calendar.HOUR) - 1));
}
dateFrom = cal.getTime();
cal = new GregorianCalendar();
if (date.equals("last week")) {
cal.set(Calendar.WEEK_OF_YEAR, cal.get(Calendar.WEEK_OF_YEAR));
cal.set(Calendar.DAY_OF_WEEK, 2);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
dateTo = cal.getTime();
}
if (date.equals("last month")) {
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH));
cal.set(Calendar.DAY_OF_MONTH,1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
dateTo = cal.getTime();
}
messageFilterStandard.setDateFrom(dateFrom);
return redirectToMessages(getMessageType().toString(), getProxyPort(), getResponderIP(),
getResponderPort(), getInitiatorIP(), getInitiatorPort(), getConnectionId(), dateFrom, dateTo,
getDicomAffectedSopClassUID(), getDicomCommandField());
} else {
log.error("Date problem");
return null;
}
}
public void setDicomRequestedSopClassUID(String dicomRequestedSopClassUID) { public void setDicomRequestedSopClassUID(String dicomRequestedSopClassUID) {
messageFilterStandard.setDicomRequestedSopClassUID(dicomRequestedSopClassUID); messageFilterStandard.setDicomRequestedSopClassUID(dicomRequestedSopClassUID);
} }
...@@ -243,7 +362,7 @@ public class MessagesBean { ...@@ -243,7 +362,7 @@ public class MessagesBean {
} }
return null; return null;
} }
public void setConnectionId(Integer connectionId) { public void setConnectionId(Integer connectionId) {
messageFilterStandard.setConnectionId(connectionId); messageFilterStandard.setConnectionId(connectionId);
} }
...@@ -330,4 +449,236 @@ public class MessagesBean { ...@@ -330,4 +449,236 @@ public class MessagesBean {
} }
} }
// public void resetField(String feild) {
//
// if (feild != null && !(feild.isEmpty())) {
// if (feild.equals("connectionId")) {
// setConnectionId(null);
// } else if (feild.equals("initiatorsIP")) {
// setInitiatorIP(null);
// } else if (feild.equals("initiatorsPort")) {
// setInitiatorPort(null);
// } else if (feild.equals("respondersIP")) {
// setResponderIP(null);
// } else if (feild.equals("respondersPort")) {
// setResponderPort(null);
// } else if (feild.equals("proxysPort")) {
// setProxyPort(null);
// } else if (feild.equals("dicomAffectedSopClassUID")) {
// setDicomAffectedSopClassUID(null);
// } else if (feild.equals("dicomCommandField")) {
// setDicomCommandField(null);
// } else if (feild.equals("dateFrom")) {
// setDateFrom(null);
// } else if (feild.equals("dateTo")) {
// setDateTo(null);
// } else {
// log.error("Feild : " + feild);
// }
// redirectToMessages(getMessageType().toString(), getProxyPort(), getResponderIP(), getResponderPort(),
// getInitiatorIP(), getInitiatorPort(), getConnectionId(), getDateFrom(), getDateTo(),
// getDicomAffectedSopClassUID(), getDicomCommandField());
// } else {
// log.error("Feild : " + feild);
// }
// }
public String redirectToMessages(String messageType, Integer proxyProviderPort, String proxyConsumerHost,
Integer proxyConsumerPort, String initiatorsIP, Integer initiatorsPort, Integer connectionId,
Date dateFrom, Date dateTo, String dicomAffectedSopClassUID, String dicomCommandField) {
log.info("messageType:" + messageType);
log.info("proxyProviderPort:" + proxyProviderPort);
log.info("proxyConsumerHost:" + proxyConsumerHost);
log.info("proxyConsumerPort:" + proxyConsumerPort);
log.info("initiatorsIP:" + initiatorsIP);
log.info("initiatorsPort:" + initiatorsPort);
log.info("connectionId:" + connectionId);
init(messageType, proxyProviderPort, proxyConsumerHost, proxyConsumerPort, initiatorsIP, initiatorsPort,
connectionId, dateFrom, dateTo, dicomAffectedSopClassUID, dicomCommandField);
log.info("messageType:" + getMessageType());
log.info("proxyProviderPort:" + getProxyPort());
log.info("proxyConsumerHost:" + getResponderIP());
log.info("proxyConsumerPort:" + getResponderPort());
log.info("initiatorsIP:" + getInitiatorIP());
log.info("initiatorsPort:" + getInitiatorPort());
log.info("connectionId:" + getConnectionId());
log.info("dateFrom:" + getDateFrom());
log.info("dateTo:" + getDateTo());
log.info("SOP:" + getDicomAffectedSopClassUID());
log.info("cmd:" + getDicomCommandField());
StringBuilder builder = new StringBuilder("");
builder.append("/messages.seam?");
builder.append("&messageType=");
builder.append(this.getMessageType());
if (proxyProviderPort != null && proxyProviderPort > 0) {
builder.append("&proxyProviderPort=");
builder.append(this.getProxyPort());
}
if (proxyConsumerHost != null && !(proxyConsumerHost.isEmpty())) {
builder.append("&proxyConsumerHost=");
builder.append(this.getResponderIP());
}
if (proxyConsumerPort != null && proxyConsumerPort > 0) {
builder.append("&proxyConsumerPort=");
builder.append(this.getResponderPort());
}
if (initiatorsIP != null && !(initiatorsIP.isEmpty())) {
builder.append("&initiatorsIP=");
builder.append(this.getInitiatorIP());
}
if (initiatorsPort != null && initiatorsPort > 0) {
builder.append("&initiatorsPort=");
builder.append(this.getInitiatorPort());
}
if (connectionId != null && connectionId > 0) {
builder.append("&connectionId=");
builder.append(this.getConnectionId());
}
if (dateFrom != null) {
builder.append("&dateFrom=");
builder.append(this.getDateFrom());
}
if (dateTo != null) {
builder.append("&dateTo=");
builder.append(this.getDateTo());
}
if (dicomAffectedSopClassUID != null && !(dicomAffectedSopClassUID.isEmpty())) {
builder.append("&dicomAffectedSopClassUID=");
builder.append(this.getDicomAffectedSopClassUID());
}
if (dicomCommandField != null && !(dicomCommandField.isEmpty())) {
builder.append("&dicomCommandField=");
builder.append(this.getDicomCommandField());
}
return builder.toString();
}
public void initFromUrl() {
Map<String, String> urlParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String messageType = null;
Integer proxyProviderPort = null;
String proxyConsumerHost = null;
Integer proxyConsumerPort = null;
String initiatorsIP = null;
Integer initiatorsPort = null;
Integer connectionId = null;
Date dateFrom = getDateFrom();
Date dateTo = getDateTo();
String dicomAffectedSopClassUID = getDicomAffectedSopClassUID();
String dicomCommandField = getDicomCommandField();
if (urlParams != null && !urlParams.isEmpty()) {
if (urlParams.containsKey("messageType")) {
messageType = urlParams.get("messageType");
}
if (urlParams.containsKey("proxyProviderPort")) {
proxyProviderPort = Integer.decode(urlParams.get("proxyProviderPort"));
}
if (urlParams.containsKey("proxyConsumerHost")) {
proxyConsumerHost = urlParams.get("proxyConsumerHost");
}
if (urlParams.containsKey("proxyConsumerPort")) {
proxyConsumerPort = Integer.decode(urlParams.get("proxyConsumerPort"));
}
if (urlParams.containsKey("initiatorsIP")) {
initiatorsIP = urlParams.get("initiatorsIP");
}
if (urlParams.containsKey("initiatorsPort")) {
initiatorsPort = Integer.decode(urlParams.get("initiatorsPort"));
}
if (urlParams.containsKey("connectionId")) {
connectionId = Integer.decode(urlParams.get("connectionId"));
}
if (urlParams.containsKey("dateFrom")) {
dateFrom = StringToDate(urlParams.get("dateFrom"));
}
if (urlParams.containsKey("dateTo")) {
dateTo = StringToDate(urlParams.get("dateTo"));
}
if (urlParams.containsKey("dicomAffectedSopClassUID")) {
dicomAffectedSopClassUID = urlParams.get("dicomAffectedSopClassUID");
}
if (urlParams.containsKey("dicomCommandField")) {
dicomCommandField = urlParams.get("dicomCommandField");
}
init(messageType, proxyProviderPort, proxyConsumerHost, proxyConsumerPort, initiatorsIP, initiatorsPort,
connectionId, dateFrom, dateTo, dicomAffectedSopClassUID, dicomCommandField);
}
}
public void init(String messageType, Integer proxyProviderPort, String proxyConsumerHost,
Integer proxyConsumerPort, String initiatorsIP, Integer initiatorsPort, Integer connectionId,
Date dateFrom, Date dateTo, String dicomAffectedSopClassUID, String dicomCommandField) {
createModel();
if (messageType != null) {
if (messageType.equals("DICOM")) {
setMessageType(ChannelType.DICOM);
} else if (messageType.equals("HL7")) {
setMessageType(ChannelType.HL7);
} else if (messageType.equals("SYSLOG")) {
setMessageType(ChannelType.SYSLOG);
} else if (messageType.equals("HTTP")) {
setMessageType(ChannelType.HTTP);
} else if (messageType.equals("RAW")) {
setMessageType(ChannelType.RAW);
}
} else {
setMessageType(ChannelType.HTTP);
}
if (proxyProviderPort != null && proxyProviderPort > 0) {
setProxyPort(proxyProviderPort);
}
if (proxyConsumerHost != null && !(proxyConsumerHost.isEmpty())) {
setResponderIP(proxyConsumerHost);
}
if (proxyConsumerPort != null && proxyConsumerPort > 0) {
setResponderPort(proxyConsumerPort);
}
if (initiatorsIP != null && !(initiatorsIP.isEmpty())) {
setInitiatorIP(initiatorsIP);
}
if (initiatorsPort != null && initiatorsPort > 0) {
setInitiatorPort(initiatorsPort);
}
if (connectionId != null && connectionId > 0) {
setConnectionId(connectionId);
}
if (dateFrom != null) {
setDateFrom(dateFrom);
}
if (dateTo != null) {
setDateTo(dateTo);
}
if (dicomAffectedSopClassUID != null && !(dicomAffectedSopClassUID.isEmpty())) {
setDicomAffectedSopClassUID(dicomAffectedSopClassUID);
}
if (dicomCommandField != null && !(dicomCommandField.isEmpty())) {
setDicomCommandField(dicomCommandField);
}
// messageDataModel.resetCache();
}
public static Date StringToDate(String dateToConvert) {
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US);
// SimpleDateFormat outputDate = new SimpleDateFormat("dd/MM/yyyy HH:mm");
Date date = null;
try {
date = sdf.parse(dateToConvert);
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
}
// System.out.println("Date: " + outputDate.format(date));
return date;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment