project works
This commit is contained in:
		| @@ -1,7 +1,6 @@ | ||||
| package com.release11; | ||||
|  | ||||
| import com.mysql.cj.jdbc.MysqlDataSource; | ||||
| import generated.MaterialType; | ||||
| import org.apache.activemq.ActiveMQConnectionFactory; | ||||
| import org.apache.camel.*; | ||||
| import org.apache.camel.builder.RouteBuilder; | ||||
| @@ -11,6 +10,14 @@ import org.apache.camel.support.SimpleRegistry; | ||||
| import org.apache.log4j.BasicConfigurator; | ||||
| import org.apache.camel.converter.jaxb.JaxbDataFormat; | ||||
| import javax.xml.bind.*; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.InputStream; | ||||
| import java.nio.file.Files; | ||||
| import java.nio.file.Path; | ||||
| import java.nio.file.Paths; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
|  | ||||
| public class Main { | ||||
| @@ -40,8 +47,7 @@ public class Main { | ||||
|  | ||||
|                 JaxbDataFormat xmlDataFormat = new JaxbDataFormat(); | ||||
|                 xmlDataFormat.setContextPath("generated"); | ||||
|                 JAXBContext jaxbContext = JAXBContext.newInstance(generated.MaterialType.class); | ||||
|                 xmlDataFormat.setContext(jaxbContext); | ||||
|                 //xmlDataFormat.setSchemaLocation("/home/igor/Documents/Jacek/jacek-and-igor/src/main/resources/material.xsd"); | ||||
|  | ||||
|                 from("direct:start") | ||||
|                         .setBody(constant("SELECT * FROM material")) | ||||
| @@ -69,29 +75,30 @@ public class Main { | ||||
|                         .to("activemq:queue:ValidMaterial") | ||||
|                         .to("log:?level=INFO&showBody=true"); | ||||
|  | ||||
|                 /* | ||||
|                 from("activemq:queue:ValidMaterial") | ||||
|                         .process(new MyProcess()) | ||||
|                         .unmarshal(xmlDataFormat) | ||||
|                         .process(exchange -> { | ||||
|                             MaterialType material = (MaterialType) exchange.getIn().getBody(); | ||||
|                             //MaterialTypeType type = material.getMaterialType(); | ||||
|                             //exchange.getIn().setHeader("type", true); | ||||
|                             //if (!(type.equals("A1") || type.equals("A2") || type.equals("A3"))) | ||||
|                             //    exchange.getIn().setHeader("type", false); | ||||
|                             //if(exchange.getIn().getHeader("type").equals(true)) | ||||
|                             System.out.println(material.toString()); | ||||
|  | ||||
|                         }); | ||||
| */ | ||||
|  | ||||
|  | ||||
|                 from("activemq:queue:siema") | ||||
|                         .process(new XMLProcess()) | ||||
|                         .unmarshal(xmlDataFormat) | ||||
|                         .process(new XMLProcess()) | ||||
|                         .to("activemq:queue:test"); | ||||
|  | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         context.start(); | ||||
|         ProducerTemplate template = context.createProducerTemplate(); | ||||
|         template.sendBody("direct:start", null); | ||||
|         Thread.sleep(1000); | ||||
|  | ||||
|         Path path = Paths.get("/home/igor/Documents/Jacek/jacek-and-igor/src/main/resources/test.xml"); | ||||
|         ArrayList<String> readAllLines = (ArrayList<String>) Files.readAllLines(path); | ||||
|         String allFile = ""; | ||||
|         for (int i = 0; i < readAllLines.size(); i++) { | ||||
|             allFile+=readAllLines.get(i); | ||||
|         } | ||||
|  | ||||
|         //template.sendBody("direct:start", null); | ||||
|         template.sendBody("activemq:queue:siema", allFile); | ||||
|  | ||||
|         context.stop(); | ||||
|     } | ||||
|   | ||||
							
								
								
									
										14
									
								
								src/main/java/com/release11/XMLProcess.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/main/java/com/release11/XMLProcess.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| package com.release11; | ||||
|  | ||||
| import org.apache.camel.Exchange; | ||||
| import org.apache.camel.Processor; | ||||
|  | ||||
| public class XMLProcess implements Processor { | ||||
|     @Override | ||||
|     public void process(Exchange exchange) throws Exception { | ||||
|         String tmp = exchange.getIn().getBody(String.class); | ||||
|         System.out.println(tmp); | ||||
|         exchange.getIn().setBody(tmp); | ||||
|  | ||||
|     } | ||||
| } | ||||
| @@ -1,13 +1,16 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||||
| <material> | ||||
|     <id>1</id> | ||||
|     <material_number>number8186</material_number> | ||||
|     <material_type>Z3</material_type> | ||||
|     <material_name>name2686</material_name> | ||||
|     <description>description7225</description> | ||||
|     <is_deleted>true</is_deleted> | ||||
|     <packages> | ||||
|         <id>1</id> | ||||
|         <material_id>1</material_id> | ||||
|         <package_number>number2274</package_number> | ||||
|         <ean>5903339152912</ean> | ||||
|         <ean>5903339152913</ean> | ||||
|         <unit_of_measure>unit1350</unit_of_measure> | ||||
|         <dimension>18x30x18</dimension> | ||||
|         <description>description7460</description> | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								target/classes/com/release11/XMLProcess.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								target/classes/com/release11/XMLProcess.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -1,13 +1,16 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||||
| <material> | ||||
|     <id>1</id> | ||||
|     <material_number>number8186</material_number> | ||||
|     <material_type>Z3</material_type> | ||||
|     <material_name>name2686</material_name> | ||||
|     <description>description7225</description> | ||||
|     <is_deleted>true</is_deleted> | ||||
|     <packages> | ||||
|         <id>1</id> | ||||
|         <material_id>1</material_id> | ||||
|         <package_number>number2274</package_number> | ||||
|         <ean>5903339152912</ean> | ||||
|         <ean>5903339152913</ean> | ||||
|         <unit_of_measure>unit1350</unit_of_measure> | ||||
|         <dimension>18x30x18</dimension> | ||||
|         <description>description7460</description> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/DAO.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/MyProcess.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/MyAggregator.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/Main.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/MergeAggregator.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/ValidatorProcess.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/XMLProcess.java | ||||
|   | ||||
| @@ -1,10 +1,6 @@ | ||||
| com/release11/Main$1.class | ||||
| com/release11/Main$1$1.class | ||||
| generated/MaterialTypeType.class | ||||
| com/release11/Main.class | ||||
| com/release11/DAO.class | ||||
| com/release11/MyProcess.class | ||||
| generated/Package.class | ||||
| com/release11/MyAggregator.class | ||||
| generated/MaterialType.class | ||||
| generated/ObjectFactory.class | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/DAO.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/target/generated-sources/jaxb/generated/MaterialType.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/target/generated-sources/jaxb/generated/Package.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/MyProcess.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/target/generated-sources/jaxb/generated/ObjectFactory.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/target/generated-sources/jaxb/generated/MaterialTypeType.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/MyAggregator.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/Main.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/MergeAggregator.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/ValidatorProcess.java | ||||
| /home/igor/Documents/Jacek/jacek-and-igor/src/main/java/com/release11/XMLProcess.java | ||||
|   | ||||
							
								
								
									
										34
									
								
								target/site-webapp/WEB-INF/web.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								target/site-webapp/WEB-INF/web.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| <!-- | ||||
| Licensed to the Apache Software Foundation (ASF) under one | ||||
| or more contributor license agreements.  See the NOTICE file | ||||
| distributed with this work for additional information | ||||
| regarding copyright ownership.  The ASF licenses this file | ||||
| to you under the Apache License, Version 2.0 (the | ||||
| "License"); you may not use this file except in compliance | ||||
| with the License.  You may obtain a copy of the License at | ||||
|  | ||||
|   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  | ||||
| Unless required by applicable law or agreed to in writing, | ||||
| software distributed under the License is distributed on an | ||||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
| KIND, either express or implied.  See the License for the | ||||
| specific language governing permissions and limitations | ||||
| under the License. | ||||
| --> | ||||
|  | ||||
| <!DOCTYPE web-app PUBLIC | ||||
|     "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | ||||
|     "http://java.sun.com/dtd/web-app_2_3.dtd" > | ||||
|  | ||||
| <web-app> | ||||
|   <filter> | ||||
|     <filter-name>doxia</filter-name> | ||||
|     <filter-class>org.apache.maven.plugins.site.webapp.DoxiaFilter</filter-class> | ||||
|   </filter> | ||||
|  | ||||
|   <filter-mapping> | ||||
|     <filter-name>doxia</filter-name> | ||||
|     <url-pattern>/*</url-pattern> | ||||
|   </filter-mapping> | ||||
| </web-app> | ||||
		Reference in New Issue
	
	Block a user