Skip to content

Commit

Permalink
- Fields didn't show when the SN didn't have NLP, Spring Boot 2.5.1 a…
Browse files Browse the repository at this point in the history
…nd Gradle 7.1
  • Loading branch information
alegauss committed Jun 18, 2021
1 parent 46ffe01 commit 6bff301
Show file tree
Hide file tree
Showing 13 changed files with 653 additions and 406 deletions.
13 changes: 0 additions & 13 deletions .jsdtscope

This file was deleted.

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -jar build/libs/viglet-turing.jar
web: java -jar turing-app/build/libs/viglet-turing.jar
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
23 changes: 0 additions & 23 deletions turGenerateDBPassword.sh

This file was deleted.

4 changes: 2 additions & 2 deletions turing-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

buildscript {
ext { springBootVersion = '2.5.0'
ext { springBootVersion = '2.5.1'
hibernateVersion = '5.11.0.Final'
httpClientVersion = '4.5.11'
swaggerVersion = '3.0.0'
Expand Down Expand Up @@ -240,7 +240,7 @@ dependencies {
implementation group: 'com.github.ulisesbocchio', name: 'jasypt-spring-boot-starter', version: "${jasyptVersion}"

// Spring
implementation group: 'org.springframework', name: 'spring-test', version: '5.3.7'
implementation group: 'org.springframework', name: 'spring-test', version: '5.3.8'

// Jackson
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5', version: '2.12.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.viglet.turing.exchange.sn.TurSNSiteExport;
import com.viglet.turing.persistence.model.sn.TurSNSite;
import com.viglet.turing.persistence.repository.sn.TurSNSiteRepository;
import com.viglet.turing.sn.template.TurSNTemplate;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Expand All @@ -53,6 +54,8 @@ public class TurSNSiteAPI {
TurSNSiteRepository turSNSiteRepository;
@Autowired
TurSNSiteExport turSNSiteExport;
@Autowired
TurSNTemplate turSNTemplate;

@ApiOperation(value = "Semantic Navigation Site List")
@GetMapping
Expand Down Expand Up @@ -92,22 +95,24 @@ public TurSNSite turSNSiteUpdate(@PathVariable String id, @RequestBody TurSNSite
turSNSiteEdit.setDefaultImageField(turSNSite.getDefaultImageField());
turSNSiteEdit.setDefaultURLField(turSNSite.getDefaultURLField());

this.turSNSiteRepository.save(turSNSiteEdit);
turSNSiteRepository.save(turSNSiteEdit);
return turSNSiteEdit;
}

@Transactional
@ApiOperation(value = "Delete a Semantic Navigation Site")
@DeleteMapping("/{id}")
public boolean turSNSiteDelete(@PathVariable String id) throws Exception {
this.turSNSiteRepository.delete(id);
turSNSiteRepository.delete(id);
return true;
}

@ApiOperation(value = "Create a Semantic Navigation Site")
@PostMapping
public TurSNSite turSNSiteAdd(@RequestBody TurSNSite turSNSite) throws Exception {
this.turSNSiteRepository.save(turSNSite);
turSNSiteRepository.save(turSNSite);
turSNTemplate.defaultSNUI(turSNSite);
turSNTemplate.createSEFields(turSNSite);
return turSNSite;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
Expand Down Expand Up @@ -52,6 +53,7 @@
import com.viglet.turing.persistence.repository.sn.TurSNSiteRepository;
import com.viglet.turing.se.field.TurSEFieldType;
import com.viglet.turing.sn.TurSNFieldType;
import com.viglet.turing.sn.template.TurSNTemplate;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Expand All @@ -71,123 +73,121 @@ public class TurSNSiteFieldExtAPI {
TurNLPInstanceEntityRepository turNLPInstanceEntityRepository;
@Autowired
TurNLPEntityRepository turNLPEntityRepository;

@Autowired
TurSNTemplate turSNTemplate;

@ApiOperation(value = "Semantic Navigation Site Field Ext List")
@Transactional
@GetMapping
public List<TurSNSiteFieldExt> turSNSiteFieldExtList(@PathVariable String snSiteId) throws JSONException {
TurSNSite turSNSite = turSNSiteRepository.findById(snSiteId).get();

List<TurSNSiteField> turSNSiteFields = turSNSiteFieldRepository.findByTurSNSite(turSNSite);
List<TurNLPInstanceEntity> turNLPInstanceEntities = turNLPInstanceEntityRepository
.findByTurNLPInstanceAndEnabled(turSNSite.getTurNLPInstance(), 1);
List<TurNLPEntity> turNLPEntityThesaurus = turNLPEntityRepository.findByLocal(1);

Map<String, TurSNSiteField> fieldMap = new HashMap<String, TurSNSiteField>();
Map<String, TurNLPEntity> nerMap = new HashMap<String, TurNLPEntity>();
Map<String, TurNLPEntity> thesaurusMap = new HashMap<String, TurNLPEntity>();

for (TurSNSiteField turSNSiteField : turSNSiteFields) {
fieldMap.put(turSNSiteField.getId(), turSNSiteField);

}

for (TurNLPInstanceEntity turNLPInstanceEntity : turNLPInstanceEntities) {
TurNLPEntity turNLPEntity = turNLPInstanceEntity.getTurNLPEntity();
nerMap.put(turNLPEntity.getId(), turNLPEntity);
}

for (TurNLPEntity turNLPEntityThesaurusSingle : turNLPEntityThesaurus) {
thesaurusMap.put(turNLPEntityThesaurusSingle.getId(), turNLPEntityThesaurusSingle);
}

List<TurSNSiteFieldExt> turSNSiteFieldExts = this.turSNSiteFieldExtRepository.findByTurSNSite(turSNSite);
Optional<TurSNSite> turSNSite = turSNSiteRepository.findById(snSiteId);

if (turSNSite.isPresent()) {
Map<String, TurSNSiteField> fieldMap = new HashMap<>();
Map<String, TurNLPEntity> nerMap = new HashMap<>();
Map<String, TurNLPEntity> thesaurusMap = new HashMap<>();

List<TurSNSiteField> turSNSiteFields = turSNSiteFieldRepository.findByTurSNSite(turSNSite.get());

if (turSNSite.get().getTurNLPInstance() != null) {
List<TurNLPInstanceEntity> turNLPInstanceEntities = turNLPInstanceEntityRepository
.findByTurNLPInstanceAndEnabled(turSNSite.get().getTurNLPInstance(), 1);
turNLPInstanceEntities.forEach(turNLPInstanceEntity -> {
TurNLPEntity turNLPEntity = turNLPInstanceEntity.getTurNLPEntity();
nerMap.put(turNLPEntity.getId(), turNLPEntity);
});
} else {
turSNSiteFieldExtRepository.deleteByTurSNSiteAndSnType(turSNSite.get(), TurSNFieldType.NER);
}
List<TurNLPEntity> turNLPEntityThesaurus = turNLPEntityRepository.findByLocal(1);

for (TurSNSiteFieldExt turSNSiteFieldExt : turSNSiteFieldExts) {
switch (turSNSiteFieldExt.getSnType()) {
case SE:
if (fieldMap.containsKey(turSNSiteFieldExt.getExternalId())) {
fieldMap.remove(turSNSiteFieldExt.getExternalId());
}
break;
case NER:
if (nerMap.containsKey(turSNSiteFieldExt.getExternalId())) {
nerMap.remove(turSNSiteFieldExt.getExternalId());
}
break;
if (turSNSiteFields.isEmpty()) {
turSNTemplate.createSEFields(turSNSite.get());
} else {
turSNSiteFields.forEach(turSNSiteField -> fieldMap.put(turSNSiteField.getId(), turSNSiteField));
}

case THESAURUS:
if (thesaurusMap.containsKey(turSNSiteFieldExt.getExternalId())) {
thesaurusMap.remove(turSNSiteFieldExt.getExternalId());
turNLPEntityThesaurus.forEach(turNLPEntityThesaurusSingle -> thesaurusMap
.put(turNLPEntityThesaurusSingle.getId(), turNLPEntityThesaurusSingle));

List<TurSNSiteFieldExt> turSNSiteFieldExts = this.turSNSiteFieldExtRepository
.findByTurSNSite(turSNSite.get());

for (TurSNSiteFieldExt turSNSiteFieldExt : turSNSiteFieldExts) {
switch (turSNSiteFieldExt.getSnType()) {
case SE:
if (fieldMap.containsKey(turSNSiteFieldExt.getExternalId())) {
fieldMap.remove(turSNSiteFieldExt.getExternalId());
}
break;
case NER:
if (nerMap.containsKey(turSNSiteFieldExt.getExternalId())) {
nerMap.remove(turSNSiteFieldExt.getExternalId());
}
break;

case THESAURUS:
if (thesaurusMap.containsKey(turSNSiteFieldExt.getExternalId())) {
thesaurusMap.remove(turSNSiteFieldExt.getExternalId());
}
break;
}
break;
}
}

for (TurSNSiteField turSNSiteField : fieldMap.values()) {
TurSNSiteFieldExt turSNSiteFieldExt = new TurSNSiteFieldExt();
turSNSiteFieldExt.setEnabled(0);
turSNSiteFieldExt.setName(turSNSiteField.getName());
turSNSiteFieldExt.setDescription(turSNSiteField.getDescription());
turSNSiteFieldExt.setFacet(0);
turSNSiteFieldExt.setFacetName(turSNSiteField.getName());
turSNSiteFieldExt.setHl(0);
turSNSiteFieldExt.setMultiValued(turSNSiteField.getMultiValued());
turSNSiteFieldExt.setMlt(0);
turSNSiteFieldExt.setExternalId(turSNSiteField.getId());
turSNSiteFieldExt.setSnType(TurSNFieldType.SE);
turSNSiteFieldExt.setType(turSNSiteField.getType());
turSNSiteFieldExt.setTurSNSite(turSNSite);
turSNSiteFieldExtRepository.save(turSNSiteFieldExt);

turSNSiteFieldExts.add(turSNSiteFieldExt);
}
for (TurSNSiteField turSNSiteField : fieldMap.values()) {
TurSNSiteFieldExt turSNSiteFieldExt = new TurSNSiteFieldExt();
turSNSiteFieldExt.setEnabled(0);
turSNSiteFieldExt.setName(turSNSiteField.getName());
turSNSiteFieldExt.setDescription(turSNSiteField.getDescription());
turSNSiteFieldExt.setFacet(0);
turSNSiteFieldExt.setFacetName(turSNSiteField.getName());
turSNSiteFieldExt.setHl(0);
turSNSiteFieldExt.setMultiValued(turSNSiteField.getMultiValued());
turSNSiteFieldExt.setMlt(0);
turSNSiteFieldExt.setExternalId(turSNSiteField.getId());
turSNSiteFieldExt.setSnType(TurSNFieldType.SE);
turSNSiteFieldExt.setType(turSNSiteField.getType());
turSNSiteFieldExt.setTurSNSite(turSNSite.get());
turSNSiteFieldExtRepository.save(turSNSiteFieldExt);

turSNSiteFieldExts.add(turSNSiteFieldExt);
}

for (TurNLPEntity turNLPEntity : nerMap.values()) {
TurSNSiteFieldExt turSNSiteFieldExt = new TurSNSiteFieldExt();
turSNSiteFieldExt.setEnabled(0);
turSNSiteFieldExt.setName(turNLPEntity.getInternalName());
turSNSiteFieldExt.setDescription(turNLPEntity.getDescription());
turSNSiteFieldExt.setFacet(0);
turSNSiteFieldExt.setFacetName(turNLPEntity.getName());
turSNSiteFieldExt.setHl(0);
turSNSiteFieldExt.setMultiValued(1);
turSNSiteFieldExt.setMlt(0);
turSNSiteFieldExt.setExternalId(turNLPEntity.getId());
turSNSiteFieldExt.setSnType(TurSNFieldType.NER);
turSNSiteFieldExt.setType(TurSEFieldType.STRING);
turSNSiteFieldExt.setTurSNSite(turSNSite);
turSNSiteFieldExtRepository.save(turSNSiteFieldExt);

turSNSiteFieldExts.add(turSNSiteFieldExt);
}
nerMap.values().forEach(turNLPEntity -> addTurSNSiteFieldExt(TurSNFieldType.NER, turSNSite,
turSNSiteFieldExts, turNLPEntity));
thesaurusMap.values().forEach(turNLPEntity -> addTurSNSiteFieldExt(TurSNFieldType.THESAURUS, turSNSite,
turSNSiteFieldExts, turNLPEntity));

for (TurNLPEntity turNLPEntity : thesaurusMap.values()) {
TurSNSiteFieldExt turSNSiteFieldExt = new TurSNSiteFieldExt();
turSNSiteFieldExt.setEnabled(0);
turSNSiteFieldExt.setName(turNLPEntity.getInternalName());
turSNSiteFieldExt.setDescription(turNLPEntity.getDescription());
turSNSiteFieldExt.setFacet(0);
turSNSiteFieldExt.setFacetName(turNLPEntity.getName());
turSNSiteFieldExt.setHl(0);
turSNSiteFieldExt.setMultiValued(1);
turSNSiteFieldExt.setMlt(0);
turSNSiteFieldExt.setExternalId(turNLPEntity.getId());
turSNSiteFieldExt.setSnType(TurSNFieldType.THESAURUS);
turSNSiteFieldExt.setType(TurSEFieldType.STRING);
turSNSiteFieldExt.setTurSNSite(turSNSite);
turSNSiteFieldExtRepository.save(turSNSiteFieldExt);

turSNSiteFieldExts.add(turSNSiteFieldExt);
return turSNSiteFieldExtRepository.findByTurSNSite(turSNSite.get());
}
return null;
}

return this.turSNSiteFieldExtRepository.findByTurSNSite(turSNSite);
private void addTurSNSiteFieldExt(TurSNFieldType turSNFieldType, Optional<TurSNSite> turSNSite,
List<TurSNSiteFieldExt> turSNSiteFieldExts, TurNLPEntity turNLPEntity) {
TurSNSiteFieldExt turSNSiteFieldExt = new TurSNSiteFieldExt();
turSNSiteFieldExt.setEnabled(0);
turSNSiteFieldExt.setName(turNLPEntity.getInternalName());
turSNSiteFieldExt.setDescription(turNLPEntity.getDescription());
turSNSiteFieldExt.setFacet(0);
turSNSiteFieldExt.setFacetName(turNLPEntity.getName());
turSNSiteFieldExt.setHl(0);
turSNSiteFieldExt.setMultiValued(1);
turSNSiteFieldExt.setMlt(0);
turSNSiteFieldExt.setExternalId(turNLPEntity.getId());
turSNSiteFieldExt.setSnType(turSNFieldType);
turSNSiteFieldExt.setType(TurSEFieldType.STRING);
turSNSiteFieldExt.setTurSNSite(turSNSite.get());
turSNSiteFieldExtRepository.save(turSNSiteFieldExt);

turSNSiteFieldExts.add(turSNSiteFieldExt);
}

@ApiOperation(value = "Show a Semantic Navigation Site Field Ext")
@GetMapping("/{id}")
public TurSNSiteFieldExt turSNSiteFieldExtGet(@PathVariable String snSiteId, @PathVariable String id)
throws JSONException {
return this.turSNSiteFieldExtRepository.findById(id).get();
return turSNSiteFieldExtRepository.findById(id).get();
}

@ApiOperation(value = "Update a Semantic Navigation Site Field Ext")
Expand Down Expand Up @@ -238,9 +238,14 @@ public boolean turSNSiteFieldExtDelete(@PathVariable String snSiteId, @PathVaria

@ApiOperation(value = "Create a Semantic Navigation Site Field Ext")
@PostMapping
public TurSNSiteFieldExt turSNSiteFieldExtAdd(@PathVariable String snSiteId, @RequestBody TurSNSiteFieldExt turSNSiteFieldExt)
throws Exception {
public TurSNSiteFieldExt turSNSiteFieldExtAdd(@PathVariable String snSiteId,
@RequestBody TurSNSiteFieldExt turSNSiteFieldExt) throws Exception {

return createSEField(snSiteId, turSNSiteFieldExt);

}

private TurSNSiteFieldExt createSEField(String snSiteId, TurSNSiteFieldExt turSNSiteFieldExt) {
TurSNSite turSNSite = turSNSiteRepository.findById(snSiteId).get();

TurSNSiteField turSNSiteField = new TurSNSiteField();
Expand All @@ -258,7 +263,6 @@ public TurSNSiteFieldExt turSNSiteFieldExtAdd(@PathVariable String snSiteId, @Re
this.turSNSiteFieldExtRepository.save(turSNSiteFieldExt);

return turSNSiteFieldExt;

}

public void updateExternalField(TurSNSiteFieldExt turSNSiteFieldExt) {
Expand All @@ -282,7 +286,8 @@ public void updateExternalField(TurSNSiteFieldExt turSNSiteFieldExt) {
break;

case THESAURUS:
TurNLPEntity turNLPEntityThesaurus = turNLPEntityRepository.findById(turSNSiteFieldExt.getExternalId()).get();
TurNLPEntity turNLPEntityThesaurus = turNLPEntityRepository.findById(turSNSiteFieldExt.getExternalId())
.get();
turNLPEntityThesaurus.setDescription(turSNSiteFieldExt.getDescription());
turNLPEntityThesaurus.setInternalName(turSNSiteFieldExt.getName());
this.turNLPEntityRepository.save(turNLPEntityThesaurus);
Expand Down Expand Up @@ -333,8 +338,7 @@ public void createField(TurSNSite turSNSite, TurSNSiteFieldExt turSNSiteFieldExt
} else {
if (turSNSiteFieldExts.getType().equals(TurSEFieldType.DATE)) {
jsonAddField.put("type", "pdate");
}
else {
} else {
jsonAddField.put("type", "text_general");
}
jsonAddField.put("multiValued", false);
Expand Down
Loading

0 comments on commit 6bff301

Please sign in to comment.