import hilfs methode für test
This commit is contained in:
parent
909c3f195d
commit
1ee7c82805
1 changed files with 59 additions and 0 deletions
|
|
@ -28,6 +28,7 @@
|
|||
package com.alexanderlogistics.api;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
|
@ -48,6 +49,7 @@ import org.imixs.workflow.exceptions.ModelException;
|
|||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.ProcessingErrorException;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
import org.imixs.workflow.xml.XMLDataCollectionAdapter;
|
||||
|
||||
import com.alexanderlogistics.BusinessPartnerService;
|
||||
import com.alexanderlogistics.InvoiceUtil;
|
||||
|
|
@ -58,10 +60,12 @@ import jakarta.ejb.TransactionAttribute;
|
|||
import jakarta.ejb.TransactionAttributeType;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
|
||||
/**
|
||||
** Dieser Service korrigiert falsch importierte Cargosoft daten.
|
||||
|
|
@ -631,6 +635,61 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Importiert vom Server Filesystem eine XML Datei
|
||||
*
|
||||
* Dies dient zum testen in dem wir unter /transfer/ xml Daten aus der
|
||||
* Produktion ablegen die wir so importiern können
|
||||
*
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/import")
|
||||
@Produces({ MediaType.TEXT_PLAIN })
|
||||
public String importXMLFile(@QueryParam("file") String filePath)
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||
PluginException, ModelException {
|
||||
StringBuffer messageBuffer = new StringBuffer();
|
||||
|
||||
if (filePath != null && filePath.endsWith(".xml")) {
|
||||
|
||||
log("├── import xml file: " + filePath, messageBuffer);
|
||||
|
||||
List<ItemCollection> col = null;
|
||||
try (InputStream inputStream = new FileInputStream(filePath)) {
|
||||
col = XMLDataCollectionAdapter.readCollectionFromInputStream(inputStream);
|
||||
if (col != null) {
|
||||
log("├── import ok - " + col.size() + " documents found", messageBuffer);
|
||||
|
||||
// Mahnwesen Process = 227af2bc-22ad-4332-8781-98ff853ca3fd
|
||||
// documentService.find(filePath, totalUpdates, totalUpdates)
|
||||
for (ItemCollection workitem : col) {
|
||||
workitem.setItemValue("process.ref", "227af2bc-22ad-4332-8781-98ff853ca3fd");
|
||||
workitem.removeItem("$immutable");
|
||||
workitem.removeItem("$snapshotid");
|
||||
workitem.setType("workitem");
|
||||
// fix id
|
||||
String id = workitem.getUniqueID();
|
||||
id = id.substring(0, id.lastIndexOf("-"));
|
||||
workitem.setItemValue("$uniqueid", id);
|
||||
log("├── import : " + id, messageBuffer);
|
||||
documentService.save(workitem);
|
||||
}
|
||||
} else {
|
||||
log("├── Import Failed: no data found!", messageBuffer);
|
||||
}
|
||||
|
||||
} catch (JAXBException | IOException e) {
|
||||
log("├── Import Failed: " + e.getMessage(), messageBuffer);
|
||||
}
|
||||
|
||||
log("├── Import finished", messageBuffer);
|
||||
|
||||
}
|
||||
|
||||
return messageBuffer.toString();
|
||||
}
|
||||
|
||||
private void log(String message, StringBuffer messageLog) {
|
||||
logger.info(message);
|
||||
messageLog.append(message + "\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue