Skip to content

Commit

Permalink
KOST-Simy v0.0.6
Browse files Browse the repository at this point in the history
================
Optimierungen und kleine Bugfix
erste Version auf Englisch und Französisch inkl. Handbücher
  • Loading branch information
Chlara committed Oct 13, 2015
1 parent d3b54be commit c159523
Show file tree
Hide file tree
Showing 19 changed files with 249 additions and 1,276 deletions.
2 changes: 1 addition & 1 deletion KOST-Simy/.classpath
Expand Up @@ -2,7 +2,7 @@
<classpath>
<classpathentry excluding="ch/kostceco/tools/kostval/validation/moduletiff2/impl/ch/kostceco/tools/kostval/validation/moduletiff2/impl/" kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.6.0_22"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="lib" path="lib/spring-context-3.0.0.RELEASE.jar" sourcepath="external-sources/spring-context-3.0.0.RELEASE-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
Expand Down
Expand Up @@ -87,16 +87,16 @@ public boolean validate( File origDatei, File repDatei, File directoryOfLogfile
imTolerance = "2%";
percentageInvalid = (float) 99.9999;
imToleranceTxt = "S";
} else if ( imToleranceTxt.contains( "L" ) || imToleranceTxt.contains( "L" ) ) {
// large = 10%
imTolerance = "10%";
percentageInvalid = (float) 99.99;
imToleranceTxt = "L";
} else if ( imToleranceTxt.contains( "XL" ) || imToleranceTxt.contains( "xl" ) ) {
// xlarge = 15%
imTolerance = "15%";
percentageInvalid = (float) 99.9;
imToleranceTxt = "XL";
} else if ( imToleranceTxt.contains( "L" ) || imToleranceTxt.contains( "l" ) ) {
// large = 10%
imTolerance = "10%";
percentageInvalid = (float) 99.99;
imToleranceTxt = "L";
} else {
// medium = 5%
imTolerance = "5%";
Expand All @@ -107,6 +107,7 @@ public boolean validate( File origDatei, File repDatei, File directoryOfLogfile

File report;
File reportId;
String imgPx1 = "1";

StringBuffer concatenatedOutputs = new StringBuffer();

Expand Down Expand Up @@ -223,7 +224,77 @@ public boolean validate( File origDatei, File repDatei, File directoryOfLogfile

// Ende IMCMP direkt auszulösen

// TODO: Marker: Report auswerten (Bildvergleich)
// TODO: Marker: ReportId und auswerten (Grösse und der Pixel)
try {
BufferedReader in = new BufferedReader( new FileReader( reportId ) );
String line;
String imgSize1 = "1";
String imgSize2 = "1";
String imgPx2 = "1";

while ( (line = in.readLine()) != null ) {

concatenatedOutputs.append( line );
concatenatedOutputs.append( NEWLINE );

/* Format: TIFF (Tagged Image File Format) Mime type: image/tiff
*
* Geometry: 2469x3568+0+0
*
* Channel statistics:
*
* Pixels: 8809392
*
* Geometry und Pixels scheinen immer ausgegeben zu werden
*
* Gemotry und Pixels müssen identisch sein */
if ( line.contains( " Geometry: " ) ) {
if ( imgSize1.equals( "1" ) ) {
imgSize1 = line;
} else {
imgSize2 = line;
}
} else if ( line.contains( " Pixels: " ) ) {
if ( imgPx1.equals( "1" ) ) {
imgPx1 = line;
} else {
imgPx2 = line;
}
}

// TODO: Marker: Auswertung und Fehlerausgabe wenn nicht bestanden.
}
if ( !imgPx1.equals( imgPx2 ) ) {
// die beiden Bilder haben nicht gleich viel Pixels
isValid = false;
getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_PIXELINVALID, imgPx1, imgPx2 ) );
}
if ( !imgSize1.equals( imgSize2 ) ) {
// die beiden Bilder sind nicht gleich gross
isValid = false;
getMessageService()
.logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_SIZEINVALID, imgSize1,
imgSize2 ) );
}
if ( !isValid ) {
// die beiden Bilder sind nicht gleich gross
in.close();
return false;
}
in.close();
} catch ( Exception e ) {
getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_UNKNOWN,
"identify: " + e.getMessage() ) );
return false;
}

// TODO: Marker: Report auswerten (Bildvergleich) wenn grösse & PixelAnzahl identisch
try {
BufferedReader in = new BufferedReader( new FileReader( report ) );
String line;
Expand All @@ -245,10 +316,10 @@ public boolean validate( File origDatei, File repDatei, File directoryOfLogfile
*
* Danach die Anzahl Pixel mit einer grösseren Abweichung aus, allg: 0= vergleichbar */
if ( line.contains( " all: " ) ) {
allExist = true;
if ( line.contains( " all: 0" ) ) {
allNull = true;
} else {
allExist = true;
/* Invalide Px extrahieren " all: 3563" extrahieren */
String lineReportAll = line.substring( 9 );
try {
Expand All @@ -272,6 +343,51 @@ public boolean validate( File origDatei, File repDatei, File directoryOfLogfile
+ getTextResourceService().getText( ERROR_XML_IMCMP_NOALL ) );
return false;
}
if ( !compResult ) {
// Bildvergleich nicht bestanden
if ( allNoInt ) {
/* Bilder mit vielen Pixels die Abweichen (Potenz -> String): Vereinfachte Fehlerausgabe */

/* Invalide [allStr] und total px z2 aus imgPx1 " Pixels: 8809392" extrahieren */
String lineReport = imgPx1.substring( 12 );
// lineReport = 8809392

isValid = false;

getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_CIINVALIDSTR, lineReport,
imToleranceTxt, allStr ) );

} else {
/* Bilder mit einer Abweichung (Int): Prozent ermitteln und mit percentageInvalid
* abgleichen */
double z1 = 0;
double z2 = 0;
float percentageCalc = (float) 0.0;
float percentageCalcInv = (float) 0.0;

/* Invalide z1 [allInt] und total px z2 aus imgPx1 " Pixels: 8809392" extrahieren */
String lineReport = imgPx1.substring( 12 );
// lineReport = 8809392
z2 = Double.parseDouble( lineReport );
z1 = allInt;

percentageCalc = (float) (100 - (100 / z2 * z1));
percentageCalcInv = 100 - percentageCalc;

// Prozentzahlen vergleichen
if ( percentageInvalid > percentageCalc ) {
// Bilder mit einer grösseren Abweichung
isValid = false;

getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_CIINVALID,
percentageCalcInv, z2, imToleranceTxt, z1 ) );
}
}
}
} catch ( Exception e ) {
getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
Expand All @@ -285,115 +401,7 @@ public boolean validate( File origDatei, File repDatei, File directoryOfLogfile
+ getTextResourceService().getText( ERROR_XML_UNKNOWN, e.getMessage() ) );
return false;
}
// TODO: Marker: ReportId und auswerten (Grösse und der Pixel)
try {
BufferedReader in = new BufferedReader( new FileReader( reportId ) );
String line;
String imgSize1 = "1";
String imgSize2 = "1";
String imgPx1 = "1";
String imgPx2 = "1";

while ( (line = in.readLine()) != null ) {

concatenatedOutputs.append( line );
concatenatedOutputs.append( NEWLINE );

/* Format: TIFF (Tagged Image File Format) Mime type: image/tiff
*
* Geometry: 2469x3568+0+0
*
* Channel statistics:
*
* Pixels: 8809392
*
* Geometry und Pixels scheinen immer ausgegeben zu werden
*
* Gemotry und Pixels müssen identisch sein */
if ( line.contains( " Geometry: " ) ) {
if ( imgSize1.equals( "1" ) ) {
imgSize1 = line;
} else {
imgSize2 = line;
}
} else if ( line.contains( " Pixels: " ) ) {
if ( imgPx1.equals( "1" ) ) {
imgPx1 = line;
} else {
imgPx2 = line;
}
}

// TODO: Marker: Auswertung und Fehlerausgabe wenn nicht bestanden.
}
if ( !imgPx1.equals( imgPx2 ) ) {
// die beiden Bilder haben nicht gleich viel Pixels
isValid = false;
getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_PIXELINVALID, imgPx1, imgPx2 ) );
}
if ( !imgSize1.equals( imgSize2 ) ) {
// die beiden Bilder sind nicht gleich gross
isValid = false;
getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_SIZEINVALID, imgSize1, imgSize2 ) );
}
if ( !compResult ) {
// Bildvergleich nicht bestanden
if ( allNoInt ) {
/* Bilder mit vielen Pixels die Abweichen (Potenz -> String): Vereinfachte Fehlerausgabe */

/* Invalide [allStr] und total px z2 aus imgPx1 " Pixels: 8809392" extrahieren */
String lineReport = imgPx1.substring( 12 );
// lineReport = 8809392

isValid = false;

getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_CIINVALIDSTR, lineReport,
imToleranceTxt, allStr ) );

} else {
/* Bilder mit einer Abweichung (Int): Prozent ermitteln und mit percentageInvalid
* abgleichen */
double z1 = 0;
double z2 = 0;
float percentageCalc = (float) 0.0;
float percentageCalcInv = (float) 0.0;

/* Invalide z1 [allInt] und total px z2 aus imgPx1 " Pixels: 8809392" extrahieren */
String lineReport = imgPx1.substring( 12 );
// lineReport = 8809392
z2 = Double.parseDouble( lineReport );
z1 = allInt;

percentageCalc = (float) (100 - (100 / z2 * z1));
percentageCalcInv = 100 - percentageCalc;

// Prozentzahlen vergleichen
if ( percentageInvalid > percentageCalc ) {
// Bilder mit einer grösseren Abweichung
isValid = false;

getMessageService().logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_CI_CIINVALID, percentageCalcInv,
z2, imToleranceTxt, z1 ) );
}
}
}
in.close();
} catch ( Exception e ) {
getMessageService()
.logError(
getTextResourceService().getText( MESSAGE_XML_MODUL_CI )
+ getTextResourceService().getText( ERROR_XML_UNKNOWN,
"identify: " + e.getMessage() ) );
return false;
}
// reports löschen
if ( report.exists() ) {
report.delete();
Expand Down
Expand Up @@ -29,11 +29,9 @@ public interface MessageConstants
String ERROR_WORKDIRECTORY_NOTDELETABLE = "error.workdirectory.notdeletable";
String ERROR_WORKDIRECTORY_NOTWRITABLE = "error.workdirectory.notwritable";
String ERROR_WORKDIRECTORY_EXISTS = "error.workdirectory.exists";
String ERROR_VALFILE_FILENOTEXISTING = "error.valfile.filenotexisting";
String ERROR_LOGGING_NOFILEAPPENDER = "error.logging.nofileappender";
String ERROR_INCORRECTFILEENDING = "error.incorrectfileending";
String ERROR_INCORRECTFILEENDINGS = "error.incorrectfileendings";
String ERROR_NOFILEENDINGS = "error.nofileendings";
String ERROR_NOREP = "error.norep";
String ERROR_NOORIGDIR = "error.noorigdir";
String ERROR_NOREPDIR1 = "error.norepdir1";
Expand All @@ -46,14 +44,14 @@ public interface MessageConstants
String MESSAGE_XML_HEADER = "message.xml.header";
String MESSAGE_XML_START = "message.xml.start";
String MESSAGE_XML_END = "message.xml.end";
String MESSAGE_XML_FORMATON = "message.xml.formaton";
String MESSAGE_XML_INFO = "message.xml.info";
String MESSAGE_COMPARISON = "message.comparison";
String MESSAGE_XML_COMPFILES = "message.compfiles";
String MESSAGE_XML_COMPFILE = "message.compfile";
String MESSAGE_XML_VALERGEBNIS = "message.xml.valergebnis";
String MESSAGE_XML_VALTYPE = "message.xml.valtype";
String MESSAGE_XML_STATISTICS = "message.xml.statistics";

String MESSAGE_XML_IMAGE1 = "message.xml.image1";
String MESSAGE_XML_IMAGE2 = "message.xml.image2";
String MESSAGE_XML_LOGEND = "message.xml.logend";
Expand Down

0 comments on commit c159523

Please sign in to comment.