rendered paste body<%! public static final String SCM_Version = "$Archive: /Auslieferung/OSERP5.1/Kundenspez/Tillotts/jsp/qla1106_ipro_till.jsp $ $Revision: 4 $ $Date: 2.09.11 18:27 $ $Modtime: 1.09.11 17:44 $ $Author: Pschmitter $"; %>
<%
//-----------------------------------------------------------------------------
// Standard - jDBV- EntryPanel unter Workflow-Kontrolle
// Version : 1.00 vom: 14.11.03
// Version von Eisbaer übernommen - noch nicht an 5.1. angepasst!
//-----------------------------------------------------------------------------
%>
<%@ page session="true" %>
<%@ page import ="java.sql.*" %>
<%@ page import ="java.util.*" %>
<%@ page import ="java.math.*" %>
<%@ page import ="java.io.*" %>
<%@ page import ="org.apache.log4j.*" %>
<%@ page import ="de.guskoeln.system.jDBV.system.*" %>
<%@ page import ="de.guskoeln.system.db.*" %>
<%@ page import ="de.guskoeln.system.dm.dialogManager.*" %>
<%@ page import ="de.guskoeln.system.utils.*" %>
<%@ page import ="de.guskoeln.system.properties.*" %>
<%@ page import ="de.guskoeln.products.os.*" %>
<%@ page import ="de.guskoeln.products.lims.bl.*" %>
<%@ page import ="de.guskoeln.products.lims.util.*" %>
<%@ page import ="de.guskoeln.system.workflow.*" %>
<jsp:useBean id="sysInfo" class="de.guskoeln.system.jDBV.system.SystemInfo" scope="session"/>
<jsp:useBean id="jspSp" class="de.guskoeln.system.dm.dialogManager.JspSp" scope="session"/>
<%! Logger logger = null; %>
<%!
/*
* Füllt die Spezifikationsfelder nach Matchcode auf Materialstamm bzw. nach
* der Eingabe einer Material Nr. und dem Speichern mit den Defaultwerten
* aus dem zugehörigen Materialstamm. Liefert true zurück, falls Änderungen
* übernommen wurden bzw. false zurück, falls es keine Unterschiede zwischen
* der (kopierten) Spezifikation und dem Materialstamm gibt. Liefert false
* zurück, falls keine Angaben übernommen wurde; true sonst.
*/
public boolean getDefaults(de.guskoeln.system.dm.dialogManager.JspSp jspSp, Connection con,
SystemInfo sysInfo) throws Exception {
boolean changed = false;
String itemNo = jspSp.with("ITEMNO").getValue();
if((itemNo != null)&&(!itemNo.trim().equals(""))) {
String sql = "SELECT DESCRIPTION, QCPERIOD, VALIDFROM, VALIDTO "
+ "FROM " + sysInfo.getSchema() + "ITEM WHERE "
+ "COMPANYNO=" + sysInfo.getCompany() + " AND "
+ "ITEMNO=" + OSString.toSql(itemNo);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(limitStmt(sysInfo, sql, 0, 1, true));
if(rs.next()) {
String descrNew = rs.getString("DESCRIPTION");
if(descrNew != null) descrNew = descrNew.trim();
else descrNew = "";
String descrOld = jspSp.with("ITEMSHORTDESCR").getValue();
if(descrOld != null) descrOld = descrOld.trim();
else descrOld = "";
if(!descrNew.equals(descrOld)) {
changed = true;
jspSp.with("ITEMSHORTDESCR").setValue(descrNew);
}
// -------------------------------------------------------------------------------
// Die Übernahme des Felds Beschreibung steuert die Übernahme weiterer Werte:
// Wurde das Feld übenommen, werden auch die nachfolgenden Angaben übernommen.
// Wurde das Feld dagegen nicht übernommen, geht die Logik davon aus, dass eine
// Übernahme bereits stattgefunden hat und ggf. nachfolgende Unterschiede
// zwischen Materialstamm und Spezifikation beabsichtigt sind (ansonsten lassen
// sich keine vom Materialstamm abweichenden Vorgaben wrfassen).
// -------------------------------------------------------------------------------
if(changed) {
jspSp.with("NUMBEROFTESTDAYS").setValue(rs.getString("QCPERIOD"));
}
OSDate osDate = new OSDate();
osDate.setLocale(sysInfo.getLocale());
String valFromNew = osDate.setJDate(rs.getDate("VALIDFROM")).getTMJJP();
if(valFromNew == null) valFromNew = "";
if(changed) {
jspSp.with("VALIDFROM").setValue(valFromNew);
}
osDate = new OSDate();
osDate.setLocale(sysInfo.getLocale());
String valToNew = osDate.setJDate(rs.getDate("VALIDTO")).getTMJJP();
if(valToNew == null) valToNew = "";
if(changed) {
jspSp.with("VALIDTO").setValue(valToNew);
}
}
rs.close();
st.close();
}
return changed;
}
/*
* Legt die nächste Spezifikationsversion fest. Über die Option specification/version/auto
* kann festgelegt werden, wie die Bestimmung laufen soll.
* 0 - keine Berechnung (muss vom Benutzer manuell vergeben werden).
* 1 - Versucht die nächste freie Spezifikationsversion zu finden und das Feld Version
* entsprechend vorzubelegen (Default).
* 2 - Wie 1, aber mit zwei stelliger Version (ggf. mit führender 0 aufgefüllt).
* 3 - Wie 2, aber die Suche nach der nächsten Version nur innerhalb eines
* Materials und eines Spezifikationstyps.
* Gibt true zurück, falls eine neue Version vorgeschlagen wird; false sonst.
*/
public boolean getVersion(de.guskoeln.system.dm.dialogManager.JspSp jspSp, Connection con,
SystemInfo sysInfo) throws Exception {
Config conf = new Config(con, sysInfo);
int versAlgorithm = Integer.parseInt(conf.getProperty("LIMS", "specification/version/auto", "1"));
// --------------------------------------------------------------------------
// Falls die Version manuell vergeben wird, wird die Methode sofort verlassen
// --------------------------------------------------------------------------
if(versAlgorithm == 0) return false;
boolean changed = false;
// --------------------------------------------------------------------------
// Evtl. erfasste Schlüssel von der JSP Seite holen
// --------------------------------------------------------------------------
String itemNo = jspSp.with("ITEMNO").getValue();
if(itemNo == null) itemNo = "";
String specType = jspSp.with("SPECIFICATIONTYPE").getValue();
if(specType == null) specType = "";
String specCode = jspSp.with("SPECIFICATIONCODE").getValue();
if(specCode == null) specCode = "";
String specVers = jspSp.with("SPECIFICATIONVERSION").getValue();
if(specVers == null) specVers = "";
// --------------------------------------------------------------------------
// Falls die Material Nr, Spezifikationstyp und Bezeichnung vorhanden sind,
// kann die nächste freie Version bestimmt werden.
// --------------------------------------------------------------------------
if((!itemNo.equals(""))&&(!specType.equals(""))&&(!specCode.equals(""))) {
int maxVersion = 0;
String sql = "SELECT SPECIFICATIONVERSION FROM " + sysInfo.getSchema() + "ITEMPROFILE WHERE "
+ "COMPANYNO=" + sysInfo.getCompany() + " AND "
+ "ITEMNO=" + OSString.toSql(itemNo) + " AND "
+ "SPECIFICATIONTYPE=" + specType;
if((versAlgorithm == 1)||(versAlgorithm == 2)){
sql += " AND SPECIFICATIONCODE=" + OSString.toSql(specCode);
}
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(limitStmt(sysInfo, sql, 0, 0, true));
while(rs.next()) {
try {
int tmpVersion = Integer.parseInt(rs.getString(1).trim());
if(tmpVersion > maxVersion) maxVersion = tmpVersion;
} catch (NumberFormatException nfe) {
// Nicht numerische Version -> ignorieren
} catch (NullPointerException npe) {
// Leere / ungültige Version -> ignorieren
}
}
rs.close();
st.close();
// --------------------------------------------------------------------------
// Die ermittelte Version mit der vorhanden Version vergleichen und ggf.
// austauchen.
// --------------------------------------------------------------------------
String leadNo = "";
if(((versAlgorithm == 2)||(versAlgorithm == 3))&&((maxVersion + 1) < 10)) leadNo = "0";
if(!specVers.trim().equals(leadNo + (maxVersion + 1))) {
changed = true;
jspSp.with("SPECIFICATIONVERSION").setValue(leadNo + (maxVersion + 1));
}
}
// --------------------------------------------------------------------------
// Falls das Feld Spezifikationsversion an dieser Stelle immer noch leer ist,
// wird das Feld als Default mit 1 vorbelegt.
// --------------------------------------------------------------------------
if((jspSp.with("SPECIFICATIONVERSION").getValue() == null)
||(jspSp.with("SPECIFICATIONVERSION").getValue().trim().equals(""))) {
if((versAlgorithm == 2)||(versAlgorithm == 3)) {
jspSp.with("SPECIFICATIONVERSION").setValue("01");
} else {
jspSp.with("SPECIFICATIONVERSION").setValue("1");
}
}
return changed;
}
%>
<%
//----------------------------------------------------------------------------------------
// Initialisierung
//----------------------------------------------------------------------------------------
Connection con = null;
synchronized (sysInfo) {
// generelle Eigenkennung
String myName = "qla1106_ipro_till";
String formatName = "qla1106_ipro";
try {
%><%@ include file="os_security_check.jinc" %><%
String projectId = sysInfo.getProjectName();
String company = sysInfo.getCompany().toString();
String schema = sysInfo.getSchema();
String user = sysInfo.getUser();
Locale locale = sysInfo.getLocale();
boolean learnMode = sysInfo.isLearnMode();
String role = sysInfo.getRole();
String sessionId = sysInfo.getSessionId();
String msg = "";
con = sysInfo.getConnection();
OSRights osRights = new OSRights(con, sysInfo);
OSI18n i18n = OSI18n.getInstance(sysInfo, con, sysInfo.getLocale(), sysInfo.isLearnMode(), myName);
String myDescr = i18n.html("Spezifikation");
// für JDBV
String formatDescr = i18n.html("Spezifikation");
String me = projectId + "/" + myName + ".jsp";
boolean qOk = true; // Ergebnis Businesslogik JDBV
boolean blocked = false; //Sperren des Ändern-Buttons bei bereits freigegebenen Prüfmethoden
String wfmId = null;
String wfmSeq = null;
OSDate osDate = new OSDate(sysInfo); // OSDate zur Umrechnung Datumsfelder
OSTex osTex = new OSTex(con, sysInfo);
OSMessage osMsg = new OSMessage(con,sysInfo);
logger = Logger.getLogger(this.getClass().getName());
//----------------------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------------------
%>
<%@ include file="osrights.jinc" %>
<%@ include file="os_header_transA.jinc" %>
<%@ include file="os_header_aux.jinc" %>
<%
//----------------------------------------------------------------------------------------
// Klassen
//----------------------------------------------------------------------------------------
class plausi {
// "Querplausibilitäten, beachten: kein Flag im Löschmodus
public boolean check (de.guskoeln.system.dm.dialogManager.JspSp jspSp, Connection con, SystemInfo sysInfo) throws Exception {
boolean checkOk = true;
/*
// wenn Spezifikationen freigabepflichtig sind, muß beim Anlegen Änderungsindex angegeben werden
Config configLims = new Config(con, sysInfo);
int releaseRequired = Integer.parseInt(configLims.getProperty("LIMS", "itemprofile/release", "1"));
if ((jspSp.getModus() == jspSp.OPEN_INSERT || jspSp.getModus() == jspSp.OPEN_COPY)
&& (releaseRequired == 1 )
&& (jspSp.with("CHANGEINDEX").getValue() == null || jspSp.with("CHANGEINDEX").getValue().trim().equals(""))) {
jspSp.with("CHANGEINDEX").setErrMsg("QLA0101");
checkOk = false;
}
*/
return checkOk;
}
}
plausi plausi = new plausi();
//--------------------------------------------------------------------------------
// Eröffnung der Transaktion
//--------------------------------------------------------------------------------
OSDCB[] dcb = openTrans(sysInfo, con, myName, request, response);
if(dcb == null) {
return;
}
OSDCB jspCb = dcb[0];
OSDCB savCb = dcb[1];
String comeFrom =jspCb.getString("COMEFROM");
String transId = jspCb.getString(myName + "_TID");
//-------------------------------------------------------------------------------------------------------------
// Seite wird von einer anderen Seite aufgerufen
// - Übernahme der Übergabe-Parameter
// - Sichern von Variablen
// - Eröffnen jDBV
//-------------------------------------------------------------------------------------------------------------
if(comeFrom.equals("CALL")) {
jspSp.openCall(sysInfo, con, jspCb, transId, formatName);
// ------------------------------------------------------------------
// Auslesen und sichern von WFMID und WFMSEQ
// ------------------------------------------------------------------
savCb.setString("wfmId",jspCb.getString("wfmId"));
savCb.setString("wfmSeq",jspCb.getString("wfmSeq"));
// -----------------------------------------------------------
// Die Seite wird mit einem entsprechenden Zusatz in der URL
// zur Kontrolle, zur Freigabe bzw. zur Workflowarchivierung
// aufgerufen. Dieser Parameter wird gespeichert.
// -----------------------------------------------------------
String cmdModus = jspCb.getString("CMDMODUS");
if(cmdModus == null) cmdModus = "";
savCb.setString("CMDMODUS", cmdModus);
if(cmdModus.equals("LOCK")) {
savCb.setString("CHECKPSW", "true");
jspSp.with("ISVALID").setValue("0");
}
// ---------------------------------------------------------------------
// bei Aufruf über Workflow ist die Material Nr. bereits bekannt und
// die Felder können mit Defaults zum spezifizierten Materialstamm
// vorbelegt werden. Beim Kopieren werden die ggf. vorhandenen (alten)
// Werte mit den Vorgaben aus dem zugehörigen Material aktualisiert.
// Ggf. die Spezifikationsversion mit einer neuen Version vorbelegen.
// ---------------------------------------------------------------------
Config configLims = new Config(con, sysInfo);
int releaseRequired = Integer.parseInt(configLims.getProperty("LIMS", "itemprofile/release", "1"));
if((jspSp.getModus() == jspSp.OPEN_INSERT)||(jspSp.getModus() == jspSp.OPEN_COPY)) {
this.getDefaults(jspSp, con, sysInfo);
this.getVersion(jspSp, con, sysInfo);
if(releaseRequired == 0) {
jspSp.with("RELEASEDBY").setValue(configLims.getProperty("SCHEDULER", "user", "maschinell"));
jspSp.with("ISVALID").setValue("1");
}
jspSp.with("ISACTIVEPROFILE").setValue("0");
/*
//-------------------------- Einschub Anfang
//Toleranzgrenze: Spezifikationstyp 5 -> Wert 1 (Toleranzgrenze 2)
// alle anderen -> Wert 0 (Toleranzgrenze 1)
//Default nur bei Neuanlage des Satzes setzen (überschreibbar vom User)
String specType = jspSp.with("SPECIFICATIONTYPE").getValue();
if(specType == null) specType = "";
if(specType.equals("5")) {
jspSp.with("TOLERANCE").setValue("1");
}
else {
jspSp.with("TOLERANCE").setValue("0");
}
//-------------------------- Einschub Ende
*/
jspSp.validateAll();
}
// ---------------------------------------------------------------------
// Beim Kopieren einer bestehenden Spezifikation werden einge der
// vorhandenen Felder zurückgesetzt. Die Materialbezeichnung wird mit
// der aktuellen Materialbezeichnung aus dem Materialstamm vorbelegt.
// ---------------------------------------------------------------------
if(jspSp.getModus() == jspSp.OPEN_COPY) {
String itemDescr = jspSp.with("ITEMSHORTDESCR").getValue();
String sql = "SELECT DESCRIPTION FROM " + sysInfo.getSchema() + "ITEM WHERE "
+ "COMPANYNO=" + sysInfo.getCompany() + " AND "
+ "ITEMNO=" + OSString.toSql(jspSp.with("ITEMNO").getValue());
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(limitStmt(sysInfo, sql, 0, 0, true));
if(rs.next()) {
itemDescr = rs.getString(1);
if((itemDescr == null)||(itemDescr.trim().equals(""))) {
itemDescr = jspSp.with("ITEMSHORTDESCR").getValue();
}
jspSp.with("ITEMSHORTDESCR").setValue(itemDescr);
}
rs.close();
stmt.close();
jspSp.startFld();
while(jspSp.hasNextFld()){
jspSp.nextFld();
if(jspSp.getFldName().equals("RELEASEDBY") || jspSp.getFldName().equals("RELEASEDATE")
|| jspSp.getFldName().equals("VALIDFROM") || jspSp.getFldName().equals("VALIDTO")
|| jspSp.getFldName().equals("C_TS") || jspSp.getFldName().equals("M_USER")
|| jspSp.getFldName().equals("M_TS")) {
jspSp.setValue("");
} else if(jspSp.getFldName().equals("ISACTIVEPROFILE") || jspSp.getFldName().equals("ISVALID")) {
jspSp.setValue("0");
}
}
if(releaseRequired == 0) {
jspSp.with("RELEASEDBY").setValue(configLims.getProperty("SCHEDULER", "user", "maschinell"));
jspSp.with("ISVALID").setValue("1");
}
//alte Schlüsselwerte sichern
savCb.setString("ITEMNO",jspCb.getString("ITEMNO"));
savCb.setString("SPECIFICATIONTYPE",jspCb.getString("SPECIFICATIONTYPE"));
savCb.setString("SPECIFICATIONCODE",jspCb.getString("SPECIFICATIONCODE"));
savCb.setString("SPECIFICATIONVERSION",jspCb.getString("SPECIFICATIONVERSION"));
}
if (jspSp.getModus() == jspSp.OPEN_UPDATE || jspSp.getModus() == jspSp.OPEN_DELETE) {
// -----------------------------------------------------------
// Falls diese Spezifikation bereits freigegeben ist und
// Prüfspezifikationen freigegeben werden müssen, ent-
// sprechend hinweisen
// -----------------------------------------------------------
if ((jspSp.with("RELEASEDBY").getSqlValue() != null) && ( !jspSp.with("RELEASEDBY").getSqlValue().trim().equals("")) && (!cmdModus.equals("LOCK"))
&& (releaseRequired == 1)) {
msg = LimsMessage.getMessage("LIM00042", con, sysInfo);
blocked = true;
// Alle Felder nur als read-only ausgeben
jspSp.startFld();
while(jspSp.hasNextFld()){
jspSp.nextFld();
jspSp.setProtect();
}
}
}
// -----------------------------------------------------------
// Gesamt-Prüfkosten berechnen
// -----------------------------------------------------------
if (jspSp.getModus() == jspSp.OPEN_UPDATE || jspSp.getModus() == jspSp.OPEN_DISPLAY) {
String costSql = "SELECT SUM(TESTCOSTS) AS SUM FROM ITEMPROFILELINE ";
costSql += " WHERE COMPANYNO = " + company;
costSql += " AND ITEMNO =" + DmStringFormatter.toSql(jspSp.with("ITEMNO").getSqlValue());
costSql += " AND SPECIFICATIONTYPE = " + jspSp.with("SPECIFICATIONTYPE").getSqlValue();
costSql += " AND SPECIFICATIONCODE = " + DmStringFormatter.toSql(jspSp.with("SPECIFICATIONCODE").getSqlValue());
costSql += " AND SPECIFICATIONVERSION = " + DmStringFormatter.toSql(jspSp.with("SPECIFICATIONVERSION").getSqlValue());
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(limitStmt(sysInfo, costSql, 0, 0, true));
if(rs.next()) {
BigDecimal bd = rs.getBigDecimal("SUM");
if (bd != null){
jspSp.with("TESTCOSTS").setValue(bd.toString().replace('.', ','));
}
}
rs.close();
stmt.close();
}
}
//--------------------------------------------------------------------------------
// Bearbeitung der Kommandos nach Selbstaufruf
//--------------------------------------------------------------------------------
if (comeFrom.equals("BACK")) {
String mtcName = savCb.getString("mtcName");
String mtcField = savCb.getString("mtcField");
savCb.remove("mtcName");
savCb.remove("mtcField");
jspSp.openBack(sysInfo, con, jspCb, request, transId, mtcName);
String cmdModus = savCb.getString("CMDMODUS");
if("ITEMNO".equals(mtcField)) {
//--------------------------------------------------------------------------------
// Nach der Auswahl über Matchcode werden ggf. Vorgaben aus dem ausgewählten
// Material übernommen und eine neue Spezifikationsversion vorgeschlagen.
//--------------------------------------------------------------------------------
if(this.getDefaults(jspSp, con, sysInfo)) {
msg = getMsgLink("QLA0051", osMsg.getMessage("QLA0051"));
}
if(this.getVersion(jspSp, con, sysInfo)) {
msg += getMsgLink("QLA0052", " " + osMsg.getMessage("QLA0052"));
}
jspSp.validateAll();
}
if (jspSp.getModus() == jspSp.OPEN_UPDATE || jspSp.getModus() == jspSp.OPEN_DELETE) {
// -----------------------------------------------------------
// Falls diese Spezifikation bereits freigegeben ist und
// Prüfspezifikationen freigegeben werden müssen, ent-
// sprechend hinweisen
// -----------------------------------------------------------
Config configLims = new Config(con, sysInfo);
int releaseRequired = Integer.parseInt(configLims.getProperty("LIMS", "itemprofile/release", "1"));
if ((jspSp.with("RELEASEDBY").getSqlValue() != null) && ( !jspSp.with("RELEASEDBY").getSqlValue().trim().equals("")) && (!cmdModus.equals("LOCK"))
&& (releaseRequired == 1)) {
msg = LimsMessage.getMessage("LIM00042", con, sysInfo);
blocked = true;
}
}
}
//--------------------------------------------------------------------------------
// Bearbeitung der Kommandos nach Selbsaufruf
//--------------------------------------------------------------------------------
if (comeFrom.equals("SELF")) {
//--------------------------------------------------------------------------------
// Rückkehr zur aufrufenden Seite. Es werden keine Parameter zurückgegeben
//--------------------------------------------------------------------------------
if(jspCb.getString("cmdCancel" + myName) != null) {
jspSp.close(transId);
insertBackTrans(sysInfo, con, myName, request, response, dcb, GOBACK);
return;
}
//--------------------------------------------------------------------------------
// jDBV-Seite eröffnen
//--------------------------------------------------------------------------------
jspSp.openSelf(sysInfo, con, jspCb, transId);
String cmdModus = savCb.getString("CMDMODUS");
//--------------------------------------------------------------------------------
// Update, Daten übernehmen
//--------------------------------------------------------------------------------
if((jspCb.getString("cmdClose") != null)||(jspCb.getString("cmdWfm") != null)) {
long specificationType = 1L;
String specificationCode = "";
String specificationVersion = "";
String itemNo = jspSp.with("ITEMNO").getValue();
boolean copied = false;
// Bei Insert prüfen, ob Kopiervorlage gewählt wurde
// falls ja und keine Spezifikationsbezeichnung vorgegeben ist, die Bezeichnung der Kopiervorlage wählen
String kopiervorlage = "";
if(jspSp.getModus() == jspSp.OPEN_INSERT) {
kopiervorlage = request.getParameter("KOPIERVORLAGE");
if ((kopiervorlage != null) && (!"".equals(kopiervorlage))) {
int index = kopiervorlage.indexOf("- Version ");
specificationVersion = kopiervorlage.substring(index+10);
kopiervorlage = kopiervorlage.substring(0,index-1);
specificationCode = jspSp.with("SPECIFICATIONCODE").getValue();
if ((specificationCode==null) || "".equals(specificationCode)) {
jspSp.with("SPECIFICATIONCODE").setValue(kopiervorlage);
specificationCode = kopiervorlage;
}
// Version evtl. hochzählen
this.getVersion(jspSp, con, sysInfo);
// Materialbezeichnung holen
this.getDefaults(jspSp, con, sysInfo);
//Spezifikation aus Kopiervorlage kopieren
ItemProfileBL ipBl = new ItemProfileBL(con, sysInfo);
ipBl.copy("KOPIERV", specificationType, kopiervorlage, specificationVersion,
itemNo, new Long(jspSp.with("SPECIFICATIONTYPE").getValue()).longValue(),
specificationCode, jspSp.with("SPECIFICATIONVERSION").getValue(),
jspSp.with("VALIDFROM").getValue(), jspSp.with("VALIDTO").getValue(), jspSp.with("ITEMSHORTDESCR").getValue());
// wenn die Spez. freigegben werden muss, dann müssen die betreffenden Felder wieder initialisiert werden
Config configLims = new Config(con, sysInfo);
int releaseRequired = Integer.parseInt(configLims.getProperty("LIMS", "itemprofile/release", "1"));
if (releaseRequired == 1) {
String sqlString = "UPDATE ITEMPROFILE SET RELEASEDBY=NULL, RELEASEDATE=NULL, ISVALID=NULL WHERE "
+ "COMPANYNO=" + company + " AND "
+ "ITEMNO=" + OSString.toSql(itemNo) + " AND "
+ "SPECIFICATIONTYPE=" + OSString.toSql(jspSp.with("SPECIFICATIONTYPE").getValue()) + " AND "
+ "SPECIFICATIONCODE=" + OSString.toSql(specificationCode) + " AND "
+ "SPECIFICATIONVERSION=" + OSString.toSql(jspSp.with("SPECIFICATIONVERSION").getValue());
logger.debug(sqlString);
Statement stmt = con.createStatement();
stmt.executeUpdate(sqlString);
}
copied=true;
}
}
//--------------------------------------------------------------------------------
// Beim Einfügen einer neuen oder Kopieren einer bestehenden Spezifikation wird
// geprüft, ob Daten aus dem Material übernommen werden müssen und ggf. eine
// neue Spezifikationsversion vergeben werden muss.
//--------------------------------------------------------------------------------
if(!copied && ((jspSp.getModus() == jspSp.OPEN_INSERT)||(jspSp.getModus() == jspSp.OPEN_COPY))) {
if(this.getDefaults(jspSp, con, sysInfo)) {
qOk = false;
msg = getMsgLink("QLA0051", osMsg.getMessage("QLA0051"));
}
if(this.getVersion(jspSp, con, sysInfo)) {
qOk = false;
msg += getMsgLink("QLA0052", " " + osMsg.getMessage("QLA0052"));
}
}
if(qOk) {
qOk = jspSp.validateAll();
if(qOk) {
qOk = plausi.check(jspSp, con, sysInfo);
if(qOk) {
// falls bei Insert aus kopiervorlage kopiert wurde, wird auch copy ausgeführt
if((jspSp.getModus() == jspSp.OPEN_COPY) || (copied && jspSp.getModus() == jspSp.OPEN_INSERT)){
if (!copied) qOk = jspSp.upd(); // sonst wurde Satz im copy schon eingefügt
if(qOk) {
WfmML wfmML = new WfmML(con, sysInfo);
ItemProfileBL itemProfileBL = new ItemProfileBL(con, sysInfo);
specificationType = Long.parseLong(jspSp.with("SPECIFICATIONTYPE").getValue());
specificationCode = jspSp.with("SPECIFICATIONCODE").getValue();
specificationVersion = jspSp.with("SPECIFICATIONVERSION").getValue();
String validFrom = null;
if (!copied){
// Kopieren mit abhängigen Daten
String itemNoOld = savCb.getString("ITEMNO");
long specificationTypeOld = Long.parseLong(savCb.getString("SPECIFICATIONTYPE"));
String specificationCodeOld = savCb.getString("SPECIFICATIONCODE");
String specificationVersionOld = savCb.getString("SPECIFICATIONVERSION");
if (jspSp.with("VALIDFROM").getValue() != null && !jspSp.with("VALIDFROM").getValue().trim().equals("")) {
osDate.setTMJJP(jspSp.with("VALIDFROM").getValue());
validFrom = osDate.getStrJMT();
}
String validTo = null;
if (jspSp.with("VALIDTO").getValue() != null && !jspSp.with("VALIDTO").getValue().trim().equals("")) {
osDate.setTMJJP(jspSp.with("VALIDTO").getValue());
validTo = osDate.getStrJMT();
}
String itemShortDescr = jspSp.with("ITEMSHORTDESCR").getValue();
itemProfileBL.copy(itemNoOld, specificationTypeOld, specificationCodeOld, specificationVersionOld,
itemNo, specificationType, specificationCode, specificationVersion,
validFrom, validTo, itemShortDescr);
}
Hashtable hashtable = new Hashtable();
hashtable.put("ITEMNO", itemNo);
hashtable.put("SPECIFICATIONTYPE", "" + specificationType);
hashtable.put("SPECIFICATIONCODE", specificationCode);
hashtable.put("SPECIFICATIONVERSION", specificationVersion);
// ------------------------------------------------------------------------------
// Auswahl des Workflow-Prozesses
// ------------------------------------------------------------------------------
int process = 0; // Default-Wert
WfmProcessML wfmProcessML = new WfmProcessML(con, sysInfo);
// 1.Versuch: Suche mit Materialklasse
String itemClass = "";
String itemSql = "SELECT ITEMCLASS FROM " + sysInfo.getSchema() + "ITEM WHERE "
+ "COMPANYNO=" + sysInfo.getCompany() + " AND "
+ "ITEMNO=" + OSString.toSql(itemNo);
Statement itemSt = con.createStatement();
ResultSet itemRs = itemSt.executeQuery(limitStmt(sysInfo, itemSql, 0, 0, true));
if(itemRs.next()) {
itemClass = itemRs.getString(1);
}
itemRs.close();
itemSt.close();
if((itemClass != null)&&(!itemClass.trim().equals(""))) {
process = wfmProcessML.getProcess("ITEMPROFILE", "ITEMCLASS=" + itemClass.trim());
}
// 2.Versuch: Suche mit Spezifikationstyp
if (process == 0) {
process = wfmProcessML.getProcess("ITEMPROFILE", "SPECIFICATIONTYPE=" + specificationType);
}
// 3.Versuch: Suche ohne Kondition
if (process == 0) {
process = wfmProcessML.getProcess("ITEMPROFILE", "");
}
// jetzt Default
if (process == 0) {
process = 1030;
}
int wfm = wfmML.create(process, new GregorianCalendar(), hashtable);
wfmML.setStartScheduled(wfm);
itemProfileBL.updateWfmId(itemNo, specificationType, specificationCode, specificationVersion,wfm);
wfmML.release(wfm);
}
} else if(jspSp.getModus() == jspSp.OPEN_DELETE) {
// Löschen mit abhängigen Daten
ItemProfileBL itemProfileBL = new ItemProfileBL(con, sysInfo);
SamplePullingBL samplePullingBL = new SamplePullingBL(con, sysInfo);
WfmML wfmML = new WfmML(con, sysInfo);
specificationType = Long.parseLong(jspSp.with("SPECIFICATIONTYPE").getValue());
specificationCode = jspSp.with("SPECIFICATIONCODE").getValue();
specificationVersion = jspSp.with("SPECIFICATIONVERSION").getValue();
int wfm = 0;
try {
wfm = Integer.parseInt(jspSp.with("WFMID").getValue());
} catch (NumberFormatException nfe){}
qOk = wfmML.requestForCancel(wfm);
if (qOk) {
wfmML.cancel(wfm);
samplePullingBL.deleteSamplePulling(itemNo, specificationType, specificationCode, specificationVersion);
itemProfileBL.deleteItemProfileLines(itemNo, specificationType, specificationCode, specificationVersion);
itemProfileBL.deleteHeader(itemNo, specificationType, specificationCode, specificationVersion);
}
} else {
// ---------------------------------------------------------------------
// Vor dem Insert wird geprüft, ob ggf. für die neue Spezifikation ein
// Workflow-Prozess eingefügt werden soll und die Prozess ID gemäß
// des neuen Prozesses über die Materialklasse des zugehörigen Materials
// bestimmt.
// ---------------------------------------------------------------------
if(jspSp.getModus() == jspSp.OPEN_INSERT) {
int processId = 0;
String itemClass = "";
String itemSql = "SELECT ITEMCLASS FROM " + sysInfo.getSchema() + "ITEM WHERE "
+ "COMPANYNO=" + sysInfo.getCompany() + " AND "
+ "ITEMNO=" + OSString.toSql(jspSp.with("ITEMNO").getValue());
Statement itemSt = con.createStatement();
ResultSet itemRs = itemSt.executeQuery(limitStmt(sysInfo, itemSql, 0, 0, true));
if(itemRs.next()) {
itemClass = itemRs.getString(1);
}
itemRs.close();
itemSt.close();
WfmProcessML wfmProcessML = new WfmProcessML(con, sysInfo);
if((itemClass != null)&&(!itemClass.trim().equals(""))) {
processId = wfmProcessML.getProcess("ITEMPROFILE", "ITEMCLASS=" + itemClass.trim());
if(processId == 0) processId = wfmProcessML.getProcess("ITEMPROFILE", "");
} else {
processId = wfmProcessML.getProcess("ITEMPROFILE", "");
}
jspSp.setProcessId(processId);
}
//--------------------------------------------------------------------------------
// Kennwort prüfen. Falls eine freigegebene Spezifikation nachtträglich geändert werden
// soll, wird die Eingabe eines Kennworts verlangt
//--------------------------------------------------------------------------------
String checkPsw = savCb.getString("CHECKPSW");
if(checkPsw == null) checkPsw = "";
if(checkPsw.equals("true")) {
String psw = jspCb.getString("PASSWORD");
if((psw == null)||((psw != null)&&(psw.trim().equals("")))) {
msg = osMsg.getMessage("MEN0001");
qOk = false;
} else {
LimsUserBL limsUserBL = new LimsUserBL(con, sysInfo);
if(!limsUserBL.isPassword2Correct(psw)) {
msg = osMsg.getMessage("MEN0001");
qOk = false;
}
}
}
if(!copied && qOk) {
qOk = jspSp.upd();
}
}
}
}
if (qOk) {
if((jspCb.getString("cmdWfm") != null)&& (!copied)) { // WF wird beim Kopieren schon geshiftet
wfmSeq = savCb.getString("wfmSeq");
wfmId = savCb.getString("wfmId");
if (wfmSeq != null) {
WfmML wfmMl = new WfmML(con, sysInfo);
wfmMl.shiftNode(new Integer(wfmId),
new Integer(wfmSeq), null, null, null, false);
request.setAttribute("myWFMID",wfmId);
}
}
jspSp.close(transId);
insertBackTrans(sysInfo, con, myName, request, response, dcb, GOBACK);
return;
}
}
if((msg == null)||(msg.trim().equals(""))) msg = jspSp.getMsg();
}
//--------------------------------------------------------------------------------
// Aufruf Matchcode selektieren und sichern
// Matchcode-Programm aufrufen
//--------------------------------------------------------------------------------
String mtcKey = jspSp.getMtc(jspCb);
if(mtcKey != null) {
String mtcHandler = jspSp.getMTCHandler(mtcKey); // Name des MC-Programms
String mtcFilter = jspSp.getMTCFilter(mtcKey);
String mtcField = jspSp.getMTCFld(mtcKey);
request.setAttribute("MTCFILTER" , mtcFilter);
request.setAttribute("ACTIONMTC" , "YES");
savCb.setString("mtcName", mtcKey);
savCb.setString("mtcField", mtcField);
insertCallTrans(sysInfo, con, myName, request, response, dcb, mtcHandler, mtcHandler, "", "N");
return;
}
}
%><%@ include file="os_commit.jinc" %><%
//--------------------------------------------------------------------------------
// HTML aufbauen
//--------------------------------------------------------------------------------
//-------------------------------------------------------------
// Modus setzen
//-------------------------------------------------------------
int noOfRecords = jspSp.getListSize();
String modustext = "";
if (jspSp.getModus() == jspSp.OPEN_INSERT) {
modustext = i18n.html("Anlegen");
}else if (jspSp.getModus() == jspSp.OPEN_UPDATE) {
modustext = i18n.html("Ändern");
}else if (jspSp.getModus() == jspSp.OPEN_DELETE) {
modustext = i18n.html("Löschen");
}else if (jspSp.getModus() == jspSp.OPEN_COPY) {
modustext = i18n.html("Kopieren");
}else if (jspSp.getModus() == jspSp.OPEN_REACT) {
modustext = i18n.html("Reaktivieren");
}
%>
<%@ include file="os_header_02.jinc" %>
<%@ include file="os_help.jinc" %>
<%= openDIV ("oscommand", "0", "oshead", "100%", "", " ") %>
<form onSubmit="return doSubmit()" action="<%= myName %>.jsp" method="post" ENCTYPE="application/x-www-form-urlencoded" NAME="<%= myName %>" ID="<%= myName %>">
<input type=hidden name=ACTION value="CALL">
<input type=hidden name=<%= myName %>_TID value=<%= jspCb.getString(myName+"_TID") %>>
<%= jspSp.getHiddenFlds() %>
<center>
<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="98%">
<tr>
<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="98%">
<tr>
<table BORDER="0" width="100%" SUMMARY="buttons zur Steuerung">
<tr>
<td align="left">
<%
if (!modustext.equals("")) {
if (((jspSp.getModus() == jspSp.OPEN_INSERT) && (osRights.isAllowed(myName, "I"))
|| (jspSp.getModus() == jspSp.OPEN_UPDATE) && (osRights.isAllowed(myName, "U"))
|| (jspSp.getModus() == jspSp.OPEN_DELETE) && (osRights.isAllowed(myName, "D"))
|| (jspSp.getModus() == jspSp.OPEN_REACT) && (osRights.isAllowed(myName, "R"))
|| (jspSp.getModus() == jspSp.OPEN_COPY) && (osRights.isAllowed(myName, "C"))) && !blocked ) {
// ---------------------------------------------------------------------
// Falls die WFMID und die SEQ bekannt sind, wird ein Button zum
// Abschluß der aktuellen Workflow Aktion angeboten
// ---------------------------------------------------------------------
if((savCb.getString("wfmSeq") != null)&&(!savCb.getString("wfmSeq").equals(""))) {
String wfmDescr = i18n.html("Erfassen Spezifikation");
String wfmSql = "SELECT DESCR FROM " + sysInfo.getSchema() + "WFM WHERE "
+ "COMPANYNO=" + sysInfo.getCompany() + " AND "
+ "WFMID=" + savCb.getString("wfmId") + " AND "
+ "SEQ=" + savCb.getString("wfmSeq");
java.sql.Statement wfmSt = con.createStatement();
ResultSet wfmRs = wfmSt.executeQuery(limitStmt(sysInfo, wfmSql, 0, 0, true));
if(wfmRs.next()) wfmDescr = wfmRs.getString(1);
if(wfmDescr != null) wfmDescr = wfmDescr.trim();
wfmRs.close();
wfmSt.close();
%>
<input type="submit" name="cmdWfm" value="<%= wfmDescr %> abschliessen" alt="<%= wfmDescr %> abschliessen"
class ="osButton"
onmouseOver="btn_mouseOver(this)"
onmouseOut="btn_mouseOut(this)">
<%
} else {
// ---------------------------------------------------------------------
// Ansonsten (nach Aufruf über Menüs) wird immer der Button Ändern
// angeboten
// ---------------------------------------------------------------------
%>
<input type="submit" name="cmdClose" value="<%= modustext %>" alt="<%= modustext %>"
class ="osButton"
onmouseOver="btn_mouseOver(this)"
onmouseOut="btn_mouseOut(this)">
<%
}
}
}
%>
<%
if (jspSp.getModus() != JspSp.OPEN_INSERT && jspSp.getModus() != JspSp.OPEN_COPY) {
out.print(getHistoryLink(jspSp.getTable(), jspSp.getPrimaryKeyAsString(),i18n));
}
%>
</td>
<td align="right">
<%
if (!modustext.equals("")) {
if ((jspSp.getModus() == jspSp.OPEN_INSERT) && (osRights.isAllowed(myName, "I"))
|| (jspSp.getModus() == jspSp.OPEN_UPDATE) && (osRights.isAllowed(myName, "U"))
|| (jspSp.getModus() == jspSp.OPEN_REACT) && (osRights.isAllowed(myName, "R"))
|| (jspSp.getModus() == jspSp.OPEN_COPY) && (osRights.isAllowed(myName, "C"))) {
%>
<input type="reset" name="cmdRefresh" value="<%=i18n.html("rücksetzen")%>" alt="<%=i18n.html("rücksetzen")%>"
class ="osButton"
onmouseOver="btn_mouseOver(this)"
onmouseOut="btn_mouseOut(this)">
<%
}
}
%>
<input type="submit" name="cmdCancel<%= myName %>" value="<%=i18n.html("abbrechen")%>" alt="<%=i18n.html("abbrechen")%>"
class ="osButton"
onmouseOver="btn_mouseOver(this)"
onmouseOut="btn_mouseOut(this)">
<%=getHelpLink(formatName,i18n)%>
</td>
</tr>
</table>
</tr>
</table>
<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="98%">
<tr>
<td>
<%= msg %>
</td>
</tr>
</table>
<%
//------------------------------------------------------------------------
// Anzeige von Kopfdaten bei Anzeigen/Ändern/Reaktivieren ...
//------------------------------------------------------------------------
if ((jspSp.getModus() == jspSp.OPEN_UPDATE) ||
(jspSp.getModus() == jspSp.OPEN_DELETE) ||
(jspSp.getModus() == jspSp.OPEN_REACT) ||
(jspSp.getModus() == jspSp.OPEN_DISPLAY)) {
out.print("<center><b>");
out.print(i18n.html("Material Nr."));
out.print(": ");
out.print(jspSp.with("ITEMNO").getValue());
out.print(", ");
out.print(i18n.html("Spezifikation"));
out.print(": ");
out.print(jspSp.with("SPECIFICATIONCODE").getValue());
out.print(", ");
out.print(i18n.html("Typ"));
out.print(" ");
out.print(osTex.getDescription("PRFTYP", jspSp.with("SPECIFICATIONTYPE").getValue()));
out.print(", ");
out.print(i18n.html("Version"));
out.print(": ");
out.print(jspSp.with("SPECIFICATIONVERSION").getValue());
out.print("</b></center>");
}
//---------------------------------------------------------------------------------------------------------------
// Scheife über alle Felder
// - falls Tab wechsel, ggf. Nachlauf Tab und Vorlauf Tab
// - Zeile mit Label, Feld und Bemerkung aufbereiten
// - im Nachlauf Tab schliessen
//---------------------------------------------------------------------------------------------------------------
%>
<%= closeDIV () %>
<%= getDIVparms("oscommand") %>
<%
// ------------------------------------------------------------------------------------
// Prüfen, ob ein zusätzliches Kennwort zum Ändern benötigt wird
// ------------------------------------------------------------------------------------
boolean doPswField = false;
String checkPsw = savCb.getString("CHECKPSW");
if(checkPsw == null) checkPsw = "";
if(checkPsw.equals("true")) {
doPswField = true;
}
int cntTab = 1;
// Kontrolle 1. Fehlermeldung bzw 1. Feld
int countFld = 0;
jspSp.startFld();
while(jspSp.hasNextFld()) {
jspSp.nextFld();
countFld ++;
if(jspSp.tabChanged()) {
if(cntTab > 1) { %>
</table>
<%= jspSp.endTab() %>
<% } %>
<%= jspSp.startTab() %>
<table border="0" cellpadding="0" cellspacing="0" width="98%" summary="Datentabelle">
<% cntTab++;
}
if(doPswField) {
doPswField = false;
%>
<% if(jspSp.getModus() == jspSp.OPEN_UPDATE) { %>
<tr ALIGN="LEFT" VALIGN="MIDDLE" CLASS="workArea">
<td width="33%"><%=getHelpLink(myName, "PASSWORD", i18n.html("Kennwort"))%></td>
<td width="33%"><input type="PASSWORD" name="PASSWORD" size="15" maxlength="15" class="txtField" value=""> </td>
<td width="34%"></td>
</tr>
<tr ALIGN="LEFT" VALIGN="MIDDLE" CLASS="workArea">
<td width="100%" colspan="3">
<hr>
</td>
</tr>
<%} %>
<%
}
if(jspSp.getDisplayType() == jspSp.DISPLAY_TYPE_TEXT) { %>
<tr ALIGN="LEFT" VALIGN="MIDDLE" CLASS="workArea">
<td width="33%">
<% if ((jspSp.getModus() == jspSp.OPEN_INSERT) && (jspSp.getFldName().equals("SPECIFICATIONTYPE"))){ %>
<%=getHelpLink(myName, "KOPIERVORLAGE", i18n.html("Kopiervorlage"))%>
<% }
else { %>
<%=getHelpLink(myName, jspSp.getFldName(), jspSp.getLabel())%>
<%} %>
</td>
<td width="33%">
<% if ((jspSp.getModus() == jspSp.OPEN_INSERT) && (jspSp.getFldName().equals("SPECIFICATIONTYPE"))){
// Dropdownbox ausgeben , es gibt keine Vorselektion
out.write("<select name=\"KOPIERVORLAGE\" class=\"dropDown\">");
// Leereintrag
out.write("<option value=\"\"> <...>" );
// alle Freigabe-Spezifikationen für das Material KOPIERV in der Dropdownbox anzeigen
String sqlIP = "SELECT SPECIFICATIONCODE, SPECIFICATIONVERSION FROM " + sysInfo.getSchema() + " ITEMPROFILE WHERE "
+ "COMPANYNO = " + sysInfo.getCompany()
+ " AND ITEMNO ='KOPIERV'"
//+ " AND SPECIFICATIONTYPE = 1" // für den Wert 1 brauchen wir ein Dropdown!!!
+ " ABD ISVALID=1";
Statement stIP = con.createStatement();
ResultSet rsIP = stIP.executeQuery(limitStmt(sysInfo, sqlIP, 0, 0, true));
while (rsIP.next()) {
String descr = rsIP.getString("SPECIFICATIONCODE") + " - Version " + rsIP.getString("SPECIFICATIONVERSION");
// Als Wert wird auch die Beschreibung angegeben, diese soll in der DB landen, da das Feld selbst nicht geschlüsselt ist
out.write("<option value=\"" + descr + "\">" + descr);
}
rsIP.close();
stIP.close();
out.write("</select>");
} else { %>
<%= jspSp.getFld() %>
<% } %>
</td>
<td width="34%"><%= jspSp.getRemark() %><%= getMsgLink(jspSp.getErrCode(), jspSp.getErrMsg()) %></td>
</tr>
<%//Spez 3999
//SPECIFICATIONTYPE wird oben ersetzt, soll jetzt aber doch angezeigt werden
//deshalb wird es hier einfach nochmals eingebaut%>
<% if ((jspSp.getModus() == jspSp.OPEN_INSERT) && (jspSp.getFldName().equals("SPECIFICATIONTYPE"))){ %>
<tr ALIGN="LEFT" VALIGN="MIDDLE" CLASS="workArea">
<td width="33%">
<%=getHelpLink(myName, jspSp.getFldName(), jspSp.getLabel())%>
</td>
<td width="33%">
<%= jspSp.getFld() %>
</td>
<td width="34%"><%= jspSp.getRemark() %><%= getMsgLink(jspSp.getErrCode(), jspSp.getErrMsg()) %></td>
</tr>
<% } %>
<%
} else if (jspSp.getDisplayType() == jspSp.DISPLAY_TYPE_TEXTAREA) {
%>
<tr ALIGN="LEFT" VALIGN="MIDDLE" CLASS="workArea">
<td width="33%">
<%=getHelpLink(myName, jspSp.getFldName(), jspSp.getLabel())%>
</td>
<td width="67%" colspan="2"><%= jspSp.getRemark() %><%= getMsgLink(jspSp.getErrCode(), jspSp.getErrMsg()) %></td>
</tr>
<tr>
<td colspan="3"><%= jspSp.getFld() %></td>
</tr>
<%
}
} %>
</table>
<%= jspSp.endTab() %>
<%= closeDIV () %>
<br>
</form>
<%
out.print(jspSp.getCursorScript(myName));
%>
<jsp:include page="os_footer.jinc" />
</body>
</html>
<%
//----------------------------------------------------------------------
// Sichern der Transaktionsdaten
//----------------------------------------------------------------------
insertSelfTrans(sysInfo, con, myName, request, response, dcb);
//----------------------------------------------------------------------
} catch (SQLException ex) {
%> <%@ include file="os_SQL_Error.jinc" %><%
} catch (Throwable ex) {
%> <%@ include file="os_Throwable.jinc" %><%
} finally {
%><%@ include file="os_Finally.jinc" %><%
} // von try
} // von synchronized
%>