Skip to content

Commit

Permalink
Merge pull request #155 from ipb-halle/feature/updateprimefaces
Browse files Browse the repository at this point in the history
Compiles with primefaces 10.0.23-LTS
  • Loading branch information
sneumann authored Oct 18, 2024
2 parents 8b170dc + 4a651a3 commit 9cf37c4
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
import org.primefaces.event.organigram.OrganigramNodeSelectEvent;
import org.primefaces.model.OrganigramNode;
import org.primefaces.model.StreamedContent;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.LineChartModel;
import org.primefaces.model.chart.LineChartSeries;

import org.primefaces.model.DefaultStreamedContent.Builder;

import de.ipbhalle.metfraglib.additionals.MathTools;
import de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException;
import de.ipbhalle.metfraglib.imagegenerator.HighlightSubStructureImageGenerator;
Expand Down Expand Up @@ -2013,7 +2016,11 @@ public org.primefaces.model.StreamedContent getDownloadParameters() {
try {
resource = this.beanSettingsContainer.getUserOutputDataHandler().getDownloadParameters(this.errorMessages, pathToProperties);
} catch(Exception e) {
resource = new org.primefaces.model.DefaultStreamedContent(System.in, "application/zip", "MetFragWeb_Parameters.zip");
resource = DefaultStreamedContent.builder()
.name("MetFragWeb_Parameters.zip")
.contentType("application/zip")
.stream(() -> System.in)
.build();
}
return resource;
}
Expand Down Expand Up @@ -2702,7 +2709,12 @@ public void closeScoresView() {
* @return
*/
public org.primefaces.model.StreamedContent generateCandidateDownloadFile() {
org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "application/vnd.ms-excel", "MetFragWeb_Candidate.xls" );
org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder()
.name("MetFragWeb_Candidate.xls")
.contentType("application/vnd.ms-excel")
.stream(() -> System.in)
.build();

try {
resource = this.beanSettingsContainer.getUserOutputDataHandler().generatedCandidateDownloadFile(this.currentScoreCandidate, this.beanSettingsContainer.getMetFragSettings());
} catch (Exception e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,22 @@ public UserOutputDataHandler(BeanSettingsContainer beanSettingsContainer) {
* @throws Exception
*/
public org.primefaces.model.StreamedContent generatedCandidateDownloadFile(MetFragResult metfragResult, Settings settings) throws Exception {
org.primefaces.model.StreamedContent resource = new DefaultStreamedContent(System.in, "application/vnd.ms-excel", "MetFragWeb_Candidate.xls" );
org.primefaces.model.StreamedContent resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Candidate.xls")
.contentType("application/vnd.ms-excel")
.stream(() -> System.in)
.build();

if(metfragResult == null) {
System.out.println("generatedCandidateDownloadFile null");
return resource;
}
resource = new DefaultStreamedContent(System.in, "application/vnd.ms-excel", "MetFragWeb_Candidate_" + metfragResult.getIdentifier() + ".xls" );

resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Candidate_" + metfragResult.getIdentifier() + ".xls")
.contentType("application/vnd.ms-excel")
.stream(() -> System.in)
.build();

//only main molecule is written to the output
Molecule root = metfragResult.getRoot();
//generate candidate for the write and set all necessary properties
Expand Down Expand Up @@ -77,7 +86,18 @@ public org.primefaces.model.StreamedContent generatedCandidateDownloadFile(MetFr
System.out.println("generating resource");
if(writer.write(scoredCandidateListSingle, "MetFragWeb_Candidate_" + candidate.getIdentifier(), folder.getAbsolutePath(), settings)) {
String filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Candidate_" + candidate.getIdentifier() + ".xls";
resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(filePath)), "application/vnd.ms-excel", "MetFragWeb_Candidate_" + candidate.getIdentifier() + ".xls");
resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Candidate_" + candidate.getIdentifier() + ".xls")
.contentType("application/vnd.ms-excel")
.stream(() -> {
try {
return new java.io.FileInputStream(new java.io.File(filePath));
} catch (Exception e) {
e.printStackTrace();
return null;
}
})
.build();
}
else return resource;
} catch (Exception e) {
Expand All @@ -96,7 +116,12 @@ public org.primefaces.model.StreamedContent generatedCandidateDownloadFile(MetFr
* @throws Exception
*/
public org.primefaces.model.StreamedContent getDownloadParameters(Messages errorMessages, String pathToProperties) throws Exception {
org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "application/zip", "MetFragWeb_Parameters.zip");
org.primefaces.model.StreamedContent resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Parameters.zip")
.contentType("application/zip")
.stream(() -> System.in)
.build();

//this.deactivateDownloadCandidatesButton();
try {
File storeFolder = this.fileStorer.prepareFolder(this.beanSettingsContainer.getRootSessionFolder() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "downloads" + Constants.OS_SPECIFIC_FILE_SEPARATOR + "parameters", errorMessages);
Expand Down Expand Up @@ -249,7 +274,20 @@ else if(library.equals("kegg")) {
inFile.close();
zos.closeEntry();
zos.close();
resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(storeFolder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Parameters.zip")), "application/zip", "MetFragWeb_Parameters.zip");
resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Parameters.zip")
.contentType("application/zip")
.stream(() -> {
try {
return new java.io.FileInputStream(new java.io.File(storeFolder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Parameters.zip"));
}
catch (Exception e) {
e.printStackTrace();
return null;
}
})
.build();

} catch (Exception e) {
errorMessages.setMessage("buttonDownloadParametersDatabaseError", "Error when downloading parameters.");
errorMessages.removeKey("buttonDownloadParametersFilterError");
Expand All @@ -269,9 +307,12 @@ else if(library.equals("kegg")) {
public org.primefaces.model.StreamedContent createCandidatesToDownload(String format, Messages errorMessages) {
System.out.println("downloadCandidates " + format);
IWriter candidateWriter = null;
String filePath = "";
org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "text/csv", "MetFragWeb_Candidates." + format);

org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder()
.name("MetFragWeb_Candidates." + format)
.contentType("text/csv")
.stream(() -> System.in)
.build();

try {
java.io.File folder = new java.io.File(this.beanSettingsContainer.getRootSessionFolder() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "downloads");
System.out.println("creating folder " + folder.getAbsolutePath());
Expand All @@ -294,8 +335,22 @@ public org.primefaces.model.StreamedContent createCandidatesToDownload(String fo
System.out.println("Error: Unknown format " + format);
}
candidateWriter.write(this.beanSettingsContainer.getRetrievedCandidateList(), "MetFragWeb_Candidates", folder.getAbsolutePath());
filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Candidates." + format;
resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(filePath)), mimetype, "MetFragWeb_Candidates." + format);
final String filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Candidates." + format;
resource = DefaultStreamedContent.builder()
.name("MetFragWeb_Candidates." + format)
.contentType(mimetype)
.stream(() -> {
try {
return new java.io.FileInputStream(new java.io.File(filePath));
} catch (Exception e) {
e.printStackTrace();
return null;
}
})



.build();
errorMessages.removeKey("buttonDownloadCompoundsError");
} catch (Exception e) {
errorMessages.setMessage("buttonDownloadCompoundsError", "Error when downloading candidates.");
Expand All @@ -314,8 +369,12 @@ public org.primefaces.model.StreamedContent createCandidatesToDownload(String fo
public org.primefaces.model.StreamedContent createResultsToDownload(MetFragResultsContainer metfragResults, String format, Messages errorMessages) {
System.out.println("downloadResults " + format);
IWriter candidateWriter = null;
String filePath = "";
org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "text/csv", "MetFragWeb_Candidates." + format);
org.primefaces.model.StreamedContent resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Candidates." + format)
.contentType("text/csv")
.stream(() -> System.in)
.build();


try {
java.io.File folder = new java.io.File(this.beanSettingsContainer.getRootSessionFolder() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "downloads");
Expand All @@ -340,8 +399,19 @@ public org.primefaces.model.StreamedContent createResultsToDownload(MetFragResul
}

candidateWriter.write(metfragResults.getScoredCandidateList(), "MetFragWeb_Results", folder.getAbsolutePath());
filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Results." + format;
resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(filePath)), mimetype, "MetFragWeb_Candidates." + format);
final String filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Results." + format;
resource = org.primefaces.model.DefaultStreamedContent.builder()
.name("MetFragWeb_Candidates." + format)
.contentType(mimetype)
.stream(() -> {
try {
return new java.io.FileInputStream(new java.io.File(filePath));
} catch (Exception e) {
e.printStackTrace();
return null;
}
})
.build();
errorMessages.removeKey("buttonDownloadResultsError");
} catch (Exception e) {
e.printStackTrace();
Expand Down
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@
<version>1.5</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.5</version>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>8.0</version>
<version>10.0.23-LTS</version>
</dependency>
<dependency>
<groupId>jakarta.platform</groupId>
Expand Down Expand Up @@ -217,6 +217,12 @@
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>primefaces-maven-repository</id>
<name>PrimeFaces Maven Repository</name>
<url>https://repository.primefaces.org/</url>
<layout>default</layout>
</repository>
<repository>
<id>msbi</id>
<url>https://msbi.ipb-halle.de/~cruttkie/maven2</url>
Expand Down

0 comments on commit 9cf37c4

Please sign in to comment.