Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/common/AbstractSeriesImport.java @ 8988:ae76f618d990
Checks added for missing import directory
author | mschaefer |
---|---|
date | Sun, 08 Apr 2018 18:09:32 +0200 |
parents | 50416a0df385 |
children | 4c5eeaff554c |
comparison
equal
deleted
inserted
replaced
8987:5ff8ce9a2e06 | 8988:ae76f618d990 |
---|---|
43 | 43 |
44 protected SERIES peer; | 44 protected SERIES peer; |
45 | 45 |
46 protected Map<StoreMode, Integer> valueStoreCount; | 46 protected Map<StoreMode, Integer> valueStoreCount; |
47 | 47 |
48 protected StoreMode seriesStoreMode; | 48 protected StoreMode storeMode; |
49 | 49 |
50 | 50 |
51 /***** CONSTRUCTORS *****/ | 51 /***** CONSTRUCTORS *****/ |
52 | 52 |
53 AbstractSeriesImport() { | 53 AbstractSeriesImport() { |
54 this.values = new ArrayList<>(); | 54 this.values = new ArrayList<>(); |
55 this.valueStoreCount = new EnumMap<>(StoreMode.class); | 55 this.valueStoreCount = new EnumMap<>(StoreMode.class); |
56 for (final StoreMode mode : StoreMode.values()) | 56 for (final StoreMode mode : StoreMode.values()) |
57 this.valueStoreCount.put(mode, Integer.valueOf(0)); | 57 this.valueStoreCount.put(mode, Integer.valueOf(0)); |
58 this.storeMode = StoreMode.NONE; | |
58 } | 59 } |
59 | 60 |
60 public AbstractSeriesImport(final String filename) { | 61 public AbstractSeriesImport(final String filename) { |
61 this(); | 62 this(); |
62 setFilename(filename); | 63 setFilename(filename); |
116 for (final StoreMode mode : StoreMode.values()) | 117 for (final StoreMode mode : StoreMode.values()) |
117 this.valueStoreCount.put(mode, Integer.valueOf(0)); | 118 this.valueStoreCount.put(mode, Integer.valueOf(0)); |
118 final SERIES peer = getPeer(river); | 119 final SERIES peer = getPeer(river); |
119 if (peer != null) { | 120 if (peer != null) { |
120 for (final KMLINE value : this.values) { | 121 for (final KMLINE value : this.values) { |
121 incrementValueStoreCount(value.store(peer, this.seriesStoreMode)); | 122 incrementValueStoreCount(value.store(peer, this.storeMode)); |
122 } | 123 } |
123 } | 124 } |
124 ImporterSession.getInstance().getDatabaseSession().flush(); | 125 ImporterSession.getInstance().getDatabaseSession().flush(); |
125 return this.seriesStoreMode; | 126 return this.storeMode; |
126 } | 127 } |
127 | 128 |
128 /** | 129 /** |
129 * Writes the store start info to the log | 130 * Writes the store start info to the log |
130 */ | 131 */ |
137 } | 138 } |
138 | 139 |
139 /** | 140 /** |
140 * Gets the model object of the data series, inserting it into the database if not already existing | 141 * Gets the model object of the data series, inserting it into the database if not already existing |
141 */ | 142 */ |
142 public SERIES getPeer(final River river) { | 143 protected SERIES getPeer(final River river) { |
143 if (this.peer != null) { | 144 if (this.peer != null) |
144 this.seriesStoreMode = StoreMode.NONE; | |
145 return this.peer; | 145 return this.peer; |
146 } | |
147 final Session session = ImporterSession.getInstance().getDatabaseSession(); | 146 final Session session = ImporterSession.getInstance().getDatabaseSession(); |
148 final List<SERIES> rows = querySeriesItem(session, river); | 147 final List<SERIES> rows = querySeriesItem(session, river); |
149 if (rows.isEmpty()) { | 148 if (rows.isEmpty()) { |
150 getLog().info("Create new database instance"); | 149 getLog().info("Create new database instance"); |
151 this.peer = createSeriesItem(river); | 150 this.peer = createSeriesItem(river); |
152 session.save(this.peer); | 151 session.save(this.peer); |
153 this.seriesStoreMode = StoreMode.INSERT; | 152 this.storeMode = StoreMode.INSERT; |
154 } else { | 153 } else { |
155 this.peer = rows.get(0); | 154 this.peer = rows.get(0); |
156 this.seriesStoreMode = StoreMode.UPDATE; | 155 this.storeMode = StoreMode.UPDATE; |
157 } | 156 } |
158 return this.peer; | 157 return this.peer; |
159 } | 158 } |
160 | 159 |
161 /** | 160 /** |