| .. | .. |
|---|
| 154 | 154 | } |
|---|
| 155 | 155 | currentapp.setName(app.getName()); |
|---|
| 156 | 156 | currentapp.setDescription(app.getDescription()); |
|---|
| 157 | | - em.persist(currentapp); |
|---|
| 157 | + em.merge(currentapp); |
|---|
| 158 | 158 | |
|---|
| 159 | 159 | Set<ApplicationMetadata> newMD = app.getApplicationMetadata(); |
|---|
| 160 | 160 | for (ApplicationMetadata currentMd : currentapp.getApplicationMetadata()) { |
|---|
| 161 | | - if (newMD == null || !newMD.contains(currentMd)) |
|---|
| 162 | | - ; |
|---|
| 163 | | - em.remove(currentMd); |
|---|
| 161 | + if (newMD == null || !newMD.contains(currentMd)) { |
|---|
| 162 | + em.remove(currentMd); |
|---|
| 163 | + } |
|---|
| 164 | 164 | } |
|---|
| 165 | 165 | |
|---|
| 166 | 166 | if (newMD != null) { |
|---|
| 167 | + Set<ApplicationMetadata> oldMD = currentapp.getApplicationMetadata(); |
|---|
| 167 | 168 | for (ApplicationMetadata md : newMD) { |
|---|
| 168 | | - md.setApplication(app); |
|---|
| 169 | | - if (md.getCreationTimestamp() == null) { |
|---|
| 170 | | - md.setCreationTimestamp(app.getCreationTimestamp()); |
|---|
| 169 | + if (oldMD.contains(md)) { |
|---|
| 170 | + em.merge(md); |
|---|
| 171 | + } else { |
|---|
| 172 | + md.setApplication(app); |
|---|
| 173 | + if (md.getCreationTimestamp() == null) { |
|---|
| 174 | + md.setCreationTimestamp(app.getCreationTimestamp()); |
|---|
| 175 | + } |
|---|
| 176 | + em.persist(md); |
|---|
| 171 | 177 | } |
|---|
| 172 | | - em.persist(md); |
|---|
| 173 | 178 | } |
|---|
| 174 | 179 | } |
|---|
| 175 | 180 | currentapp.setApplicationMetadata(app.getApplicationMetadata()); |
|---|