feature/config #78
@ -1,3 +1,8 @@
 | 
			
		||||
!!org.hso.ecommerce.app.config.YAMLData {companyName: newCommerce GmbH, installationName: Fast-Web-Shop,
 | 
			
		||||
  numberOfStorageSpaces: 128, parcelServiceApiURL: 'https://dhl.api.ecommerce.mosad.xyz',
 | 
			
		||||
  parcelServiceName: DHL International GmbH}
 | 
			
		||||
!!org.hso.ecommerce.app.config.YAMLData
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 | 
			||||
companyAddress: {cityName: Berlin, countryName: Germany, houseNumber: '6', streetName: Kupfergraben,
 | 
			
		||||
  zipCode: '10117'}
 | 
			
		||||
companyName: newCommerce GmbH
 | 
			
		||||
installationName: Fast-Web-Shop
 | 
			
		||||
numberOfStorageSpaces: 128
 | 
			
		||||
parcelServiceApiURL: https://dhl.api.ecommerce.mosad.xyz
 | 
			
		||||
parcelServiceName: DHL International GmbH
 | 
			
		||||
 | 
			
		||||
@ -18,13 +18,10 @@ public class Application {
 | 
			
		||||
    	
 | 
			
		||||
    	AppSettings appSettings =  AppSettings.getInstance(); // This does not belongs here
 | 
			
		||||
    	
 | 
			
		||||
    	//appSettings.writeDemoConfig();
 | 
			
		||||
    	appSettings.writeDemoConfig();
 | 
			
		||||
    	
 | 
			
		||||
    	appSettings.readConfig(); // This does not belongs here either
 | 
			
		||||
    	
 | 
			
		||||
    	
 | 
			
		||||
    	
 | 
			
		||||
    	
 | 
			
		||||
        //SpringApplication.run(Application.class, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,7 @@ import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.hso.ecommerce.app.config.YAMLData.Address;
 | 
			
		||||
import org.yaml.snakeyaml.Yaml;
 | 
			
		||||
import org.yaml.snakeyaml.constructor.Constructor;
 | 
			
		||||
 | 
			
		||||
@ -35,7 +36,7 @@ public class AppSettings {
 | 
			
		||||
 | 
			
		||||
		data.setInstallationName("Fast-Web-Shop");
 | 
			
		||||
		data.setCompanyName("newCommerce GmbH");
 | 
			
		||||
		//data.setCompanyAddress(new Address("Kupfergraben", "6", "10117", "Berlin", "Germany"));
 | 
			
		||||
		data.setCompanyAddress(new Address("Kupfergraben", "6", "10117", "Berlin", "Germany"));
 | 
			
		||||
		data.setNumberOfStorageSpaces(128);
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
@ -67,23 +68,23 @@ public class AppSettings {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void readConfig() {
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
	    Yaml yaml = new Yaml(new Constructor(YAMLData.class));
 | 
			
		||||
	    InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("./eCommerce_config.yml");
 | 
			
		||||
	    YAMLData data = yaml.load(inputStream);
 | 
			
		||||
		*/
 | 
			
		||||
		  String input = "!!org.hso.ecommerce.app.config.YAMLData {companyName: newCommerce GmbH, installationName: Fast-Web-Shop,\n" + 
 | 
			
		||||
		  		"  numberOfStorageSpaces: 128, parcelServiceApiURL: 'https://dhl.api.ecommerce.mosad.xyz',\n" + 
 | 
			
		||||
		  		"  parcelServiceName: DHL International GmbH}\n" + 
 | 
			
		||||
		  		"";
 | 
			
		||||
 | 
			
		||||
	    InputStream inputStream;
 | 
			
		||||
		try {
 | 
			
		||||
			inputStream = new FileInputStream("./eCommerce_config.yml");
 | 
			
		||||
		
 | 
			
		||||
		    YAMLData data = yaml.load(inputStream);
 | 
			
		||||
		    
 | 
			
		||||
		    System.out.println(data.getCompanyName());
 | 
			
		||||
		    
 | 
			
		||||
		} catch (FileNotFoundException e) {
 | 
			
		||||
			// TODO Auto-generated catch block
 | 
			
		||||
			e.printStackTrace();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		  Yaml yaml = new Yaml(new Constructor(YAMLData.class));
 | 
			
		||||
		  
 | 
			
		||||
		  	
 | 
			
		||||
		  YAMLData data = yaml.load(input);
 | 
			
		||||
		  
 | 
			
		||||
		  System.out.println(data.getCompanyName());
 | 
			
		||||
		  
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -7,7 +7,7 @@ public class YAMLData {
 | 
			
		||||
 | 
			
		||||
	private String installationName;
 | 
			
		||||
	private String companyName;
 | 
			
		||||
	//private Address companyAddress;
 | 
			
		||||
	private Address companyAddress;
 | 
			
		||||
	private int numberOfStorageSpaces;
 | 
			
		||||
	//private List<Supplier> suppliers;
 | 
			
		||||
	private String parcelServiceName;
 | 
			
		||||
@ -26,14 +26,14 @@ public class YAMLData {
 | 
			
		||||
	public void setCompanyName(String companyName) {
 | 
			
		||||
		this.companyName = companyName;
 | 
			
		||||
	}
 | 
			
		||||
	/*
 | 
			
		||||
	
 | 
			
		||||
	public Address getCompanyAddress() {
 | 
			
		||||
		return companyAddress;
 | 
			
		||||
	}
 | 
			
		||||
	public void setCompanyAddress(Address companyAddress) {
 | 
			
		||||
		this.companyAddress = companyAddress;
 | 
			
		||||
	}
 | 
			
		||||
	*/
 | 
			
		||||
	
 | 
			
		||||
	public int getNumberOfStorageSpaces() {
 | 
			
		||||
		return numberOfStorageSpaces;
 | 
			
		||||
	}
 | 
			
		||||
@ -60,7 +60,7 @@ public class YAMLData {
 | 
			
		||||
	public void setParcelServiceApiURL(String parcelServiceApiURL) {
 | 
			
		||||
		this.parcelServiceApiURL = parcelServiceApiURL;
 | 
			
		||||
	}
 | 
			
		||||
	/*
 | 
			
		||||
	
 | 
			
		||||
	public static class Address {
 | 
			
		||||
 | 
			
		||||
		public String streetName;
 | 
			
		||||
@ -77,7 +77,7 @@ public class YAMLData {
 | 
			
		||||
			this.countryName = countryName;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
	public static class Supplier {
 | 
			
		||||
 | 
			
		||||
		public String name;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user
	
Würde eher nicht unter dem "echten" Dateinamen mit falschen Daten ins Repo commiten.
Vlcht eher "example_config.yml" oder in ne Art readme rein pasten und drüber den Pfad.
Oder Alternativ eine funktionierende Konfiguration.
Ohne die Datei startet die Anwendung halt nicht mehr.