SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

120 lines
5.0 KiB

package de.superx.servlet;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import de.superx.BaseDbTest;
import de.superx.TestApplicationConfigH2;
import de.superx.TestApplicationConfigPg;
import de.superx.bin.ExecuteMask;
//@ContextConfiguration(classes = { TestApplicationConfigPg.class })
public class PublikationsauswertungTest extends BaseDbTest {
private static final String STUDENTS_FACTSHEET_NAME = "Publikationsauswertung";
protected static final String WEB_INF_PATH = "superx" + File.separator + "WEB-INF";
protected static final String WEB_INF_PFAD_ABSOLUT=new File(WEB_INF_PATH).getAbsolutePath();
private static String outputFilename = String.join(File.separator, "test", "output_610040.xlsx");
private static File outputFile = new File(outputFilename);
@Test
@Ignore
public void testXslxDatenblatt()
throws Exception {
String[] params = buildParams("610040_anteil_open_access_publikationen.jrxml");
ExecuteMask.setMyWEBINFFilePath(WEB_INF_PFAD_ABSOLUT);
ExecuteMask.execute(params);
validateXSLXFile();
}
private static String[] buildParams(String stylesheet) {
String contenttype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
String validierungsstatus ="";
String publikationstyp ="";
String dokumenttyp ="";
String schoepfertyp="";
String qualifikationsschrift = "";
String peer_reviewed = "";
String darstellungsform = "";
String zugangsrecht = "";
String zeitung_zeitschrift ="";
String verlag ="";
String konferenz ="";
String zugangsrecht_des_uebergeordneten_Werks="";
String interne_affiliation ="";
String externe_affiliation ="";
//String fachgebiet="Geisteswissenschaften allgemein,Finanzwissenschaft,Bankwesen";
String fachgebiet="1,208,193";
String sprache ="";
//String forschungsfeld="";
String forschungsfeld="";
String hochschuleigene_klassifikation ="";
String sichtbarkeit ="";
String project="";
String[] params = {
"-tid:610040",
"-out:" + outputFilename,
"-user:admin",
"-params:"
+ "&stylesheet=" + stylesheet
+ "&tablestylesheet=" + stylesheet
+ "&contenttype=" + contenttype
+ "&Publikationstyp=" + publikationstyp
+ "&Validierungsstatus=" + validierungsstatus
+ "&Dokumenttyp=" + dokumenttyp
+ "&Schöpfertyp=" + schoepfertyp
+ "&Art der Qualifikationsschrift=" + qualifikationsschrift
+ "&Peer-reviewed=" + peer_reviewed
+ "&Darstellungsform=" + darstellungsform
+ "&Zugangsrecht der Publikation=" + zugangsrecht
+ "&Zeitung/Zeitschrift=" + zeitung_zeitschrift
+ "&Verlag=" + verlag
+ "&Konferenz=" + konferenz
+ "&Zugangsrecht übergeordnetes Werk=" + zugangsrecht_des_uebergeordneten_Werks
+ "&Interne Affiliation=" + interne_affiliation
+ "&Externe Affiliation=" + externe_affiliation
+ "&Fachgebiet=" + fachgebiet
+ "&Sprache=" + sprache
+ "&Forschungsfeld=" + forschungsfeld
+ "&Hochschuleigene Klassifikation=" + hochschuleigene_klassifikation
+ "&Sichtbarkeit=" + sichtbarkeit
+ "&Projekt=" + project,
"-logger:" + logConfigPath,
"-mandantenID:" + TestApplicationConfigH2.TEST_MANDANTEN_ID };
return params;
}
private static void validateXSLXFile() throws IOException, InvalidFormatException {
Assert.assertTrue("'" + outputFilename + " ("+outputFile.getCanonicalPath()+") does not exist", outputFile.exists());
boolean studendsFactSheetFound = containsStudentsFactSheet(outputFile);
Assert.assertTrue("'" + outputFilename + "' misses sheet '" + STUDENTS_FACTSHEET_NAME + "'",
studendsFactSheetFound);
}
private static boolean containsStudentsFactSheet(File xslxFile)
throws IOException, InvalidFormatException {
boolean studendsFactSheetFound = false;
try (XSSFWorkbook workbook = new XSSFWorkbook(xslxFile);) {
Iterator<Sheet> shit = workbook.sheetIterator();
while (shit.hasNext()) {
Sheet sheet = shit.next();
String sheetName = sheet.getSheetName();
studendsFactSheetFound |= sheetName.equals(STUDENTS_FACTSHEET_NAME);
}
}
return studendsFactSheetFound;
}
}