1919import java .net .http .HttpClient ;
2020import java .net .http .HttpRequest ;
2121import java .net .http .HttpResponse ;
22- import java .util .HashMap ;
23- import java .util .Map ;
24- import java .util .Set ;
22+ import java .util .*;
2523
2624@ Service
2725public class ConfigurationService {
@@ -48,12 +46,7 @@ public static Map<Resource, Map<Property, Configuration>> fetchConfigForObjects(
4846 public static Map <Property , Configuration > createFlatConfig (Map <Resource , Map <Property , Configuration >> configs ) {
4947 Map <Property , Configuration > flatConfig = new HashMap <>();
5048 for (Map <Property , Configuration > configMap : configs .values ()) {
51- for (Map .Entry <Property , Configuration > entry : configMap .entrySet ()) {
52- if (flatConfig .containsKey (entry .getKey ())) {
53- throw new OntologyException ("Duplicate Property key found in Flat Ontology: " + entry .getKey ());
54- }
55- flatConfig .put (entry .getKey (), entry .getValue ());
56- }
49+ flatConfig .putAll (configMap );
5750 }
5851 return flatConfig ;
5952 }
@@ -107,8 +100,15 @@ private static String fetchStringContent(String url) {
107100 @ NotNull
108101 private static Map <Resource , Map <Property , Configuration >> extractConfig (Model model ) {
109102 Map <Resource , Map <Property , Configuration >> configs = new HashMap <>();
103+ Set <Property > properties = new HashSet <>();
110104 logger .info ("Extracting configuration from server response" );
111105 QueryService .getConfigurations (model ).forEach (entry -> {
106+ if (properties .contains (entry .property ())) {
107+ throw new OntologyException (
108+ "Duplicate Property key found in Ontology: " + entry .property ().toString ()
109+ );
110+ }
111+ properties .add (entry .property ());
112112 if (!configs .containsKey (entry .object ())) {
113113 configs .put (entry .object (), new HashMap <>());
114114 }
0 commit comments