Commit 2fdd05ecfbcba698912a95666cbad71ce4f580de
1 parent
2ed91a45
Exists in
master
Correção na importação de dataObject
Showing
1 changed file
with
13 additions
and
10 deletions
Show diff stats
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/service/impl/DataObjectServiceImpl.java
| ... | ... | @@ -701,28 +701,31 @@ public class DataObjectServiceImpl extends GenericServiceImpl<DataObject, Long> |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | + String typeName = dataColumn.getType().getName(); | |
| 704 | 705 | dataColumn.setId(null); |
| 705 | - String name = dataColumn.getType().getName(); | |
| 706 | 706 | if (DBColumn != null) { |
| 707 | 707 | dataColumn.setDatabaseType(DBColumn.getDatabaseType()); |
| 708 | 708 | dataColumn.setType(DBColumn.getType()); |
| 709 | 709 | }else{ |
| 710 | - dataColumn.setType(dataTypeService.findByName(name)); | |
| 710 | + dataColumn.setType(dataTypeService.findByName(typeName)); | |
| 711 | 711 | if (dataColumn.getType() == null) { |
| 712 | - String databaseType = dataColumn.getDatabaseType() != null ? dataColumn.getDatabaseType() : name; | |
| 712 | + throw new EsiBusinessException("Tipo de dados '"+typeName+"' não encontrado"); | |
| 713 | + } | |
| 714 | + | |
| 715 | + if (!UtilString.isNullOrEmpty(dataColumn.getDatabaseType())) { | |
| 716 | + boolean exists = false; | |
| 713 | 717 | for (DatabaseDomain domain : database.getTypes()) { |
| 714 | - if (domain.getName().equalsIgnoreCase(databaseType)) { | |
| 715 | - dataColumn.setType(domain.getDataType()); | |
| 718 | + if (domain.getDataType().equals(dataColumn.getType().getId()) && domain.getName().equalsIgnoreCase(dataColumn.getDatabaseType())) { | |
| 719 | + exists = true; | |
| 716 | 720 | break; |
| 717 | 721 | } |
| 718 | 722 | } |
| 723 | + if (!exists) { | |
| 724 | + dataColumn.setDatabaseType(null); | |
| 725 | + } | |
| 719 | 726 | } |
| 720 | 727 | } |
| 721 | 728 | |
| 722 | - if (dataColumn.getType() == null) { | |
| 723 | - throw new EsiBusinessException("Tipo de dados '"+name+"' não encontrado"); | |
| 724 | - } | |
| 725 | - | |
| 726 | 729 | if (UtilString.isNullOrEmpty(dataColumn.getDatabaseType())) { |
| 727 | 730 | for (DatabaseDomain domain : database.getTypes()) { |
| 728 | 731 | if (domain.getDataType().getId().equals(dataColumn.getType().getId())) { |
| ... | ... | @@ -733,7 +736,7 @@ public class DataObjectServiceImpl extends GenericServiceImpl<DataObject, Long> |
| 733 | 736 | } |
| 734 | 737 | |
| 735 | 738 | if (UtilString.isNullOrEmpty(dataColumn.getDatabaseType())) { |
| 736 | - throw new EsiBusinessException("Tipo de dados '"+name+"' não encontrado no BD"); | |
| 739 | + throw new EsiBusinessException("Tipo de dados '" + typeName + "' não encontrado no BD"); | |
| 737 | 740 | } |
| 738 | 741 | |
| 739 | 742 | if (dataColumn.getWidget() != null) { | ... | ... |