Browse Source
Merge pull request #63 from deaflynx/develop/2.6-edge
Develop/2.6 edge fixed saveEdge, importEdge
pull/3693/head
VoBa
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
28 additions and
1 deletions
-
dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java
-
ui/src/app/import-export/import-export.service.js
-
ui/src/app/locale/locale.constant-en_US.json
|
|
|
@ -25,6 +25,7 @@ import org.apache.http.HttpHost; |
|
|
|
import org.apache.http.conn.ssl.DefaultHostnameVerifier; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
|
import org.hibernate.exception.ConstraintViolationException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.cache.Cache; |
|
|
|
@ -172,7 +173,22 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic |
|
|
|
public Edge saveEdge(Edge edge) { |
|
|
|
log.trace("Executing saveEdge [{}]", edge); |
|
|
|
edgeValidator.validate(edge, Edge::getTenantId); |
|
|
|
return edgeDao.save(edge.getTenantId(), edge); |
|
|
|
Edge savedEdge; |
|
|
|
if (!sqlDatabaseUsed) { |
|
|
|
savedEdge = edgeDao.save(edge.getTenantId(), edge); |
|
|
|
} else { |
|
|
|
try { |
|
|
|
savedEdge = edgeDao.save(edge.getTenantId(), edge); |
|
|
|
} catch (Exception t) { |
|
|
|
ConstraintViolationException e = extractConstraintViolationException(t).orElse(null); |
|
|
|
if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("edge_name_unq_key")) { |
|
|
|
throw new DataValidationException("Edge with such name already exists!"); |
|
|
|
} else { |
|
|
|
throw t; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return savedEdge; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@ -614,6 +614,16 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document, |
|
|
|
} |
|
|
|
); |
|
|
|
return deferred.promise; |
|
|
|
case types.entityType.edge: |
|
|
|
openImportDialogCSV($event, entityType, 'edge.import', 'edge.edge-file').then( |
|
|
|
function success() { |
|
|
|
deferred.resolve(); |
|
|
|
}, |
|
|
|
function fail() { |
|
|
|
deferred.reject(); |
|
|
|
} |
|
|
|
); |
|
|
|
return deferred.promise; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -765,6 +765,7 @@ |
|
|
|
"edge": { |
|
|
|
"edge": "Edge", |
|
|
|
"edges": "Edges", |
|
|
|
"edge-file": "Edge file", |
|
|
|
"management": "Edge management", |
|
|
|
"no-edges-matching": "No edges matching '{{entity}}' were found.", |
|
|
|
"add": "Add Edge", |
|
|
|
|