Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
unused imports
reorder modifiers should be declared in the correct order to comply with the Java Language specification
rename fields or methods with lower case at the beginning
return directly a result
  • Loading branch information
GtanSndil committed Feb 15, 2024
1 parent 2f25829 commit 9c0b026
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@RequestMapping("/Item")
@Tag(name= "DEMO-Colectica",description = "Services for upgrade Colectica-API")
public class GetItem {
final static Logger logger = LogManager.getLogger(GetItem.class);
static final Logger logger = LogManager.getLogger(GetItem.class);

private final ColecticaService colecticaService;

Expand All @@ -32,7 +32,7 @@ public GetItem(ColecticaService colecticaService) {
@GetMapping("ddiInstance/uuid")
@Operation(summary = "Get ddiInstance by uuid", description = "Get an XML document for a ddi:Instance from Colectica repository.")
@Produces(MediaType.APPLICATION_XML)
public ResponseEntity<String> FindInstanceByUuidColectica (
public ResponseEntity<String> findInstanceByUuidColectica(
@Parameter(
description = "id de l'objet colectica",
required = true,
Expand All @@ -45,7 +45,7 @@ public ResponseEntity<String> FindInstanceByUuidColectica (
@GetMapping("ddiFragment/uuid")
@Operation(summary = "Get Fragment by uuid", description = "Get an XML document for a ddi:Fragment from Colectica repository.")
@Produces(MediaType.APPLICATION_XML)
public ResponseEntity<String> FindFragmentByUuidColectica (
public ResponseEntity<String> findFragmentByUuidColectica(
@Parameter(
description = "id de l'objet colectica",
required = true,
Expand Down Expand Up @@ -98,7 +98,7 @@ public ResponseEntity<String> filteredSearchTextByType(

@GetMapping("/filtered-search/type/")
@Operation(summary = "Get list of match by type in elasticsearch database", description = "Get a JSON ")
public ResponseEntity<String> SearchByType(
public ResponseEntity<String> searchByType(
@Parameter(
description = "nom par défaut de l'index colectica",
required = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
})
public class PostItem {

final static Logger log = LogManager.getLogger(PostItem.class);
static final Logger log = LogManager.getLogger(PostItem.class);
private final ResourceLoader resourceLoader;

private final ColecticaService colecticaService;
Expand Down Expand Up @@ -111,7 +111,7 @@ public ResponseEntity<String> uploadItem(@RequestParam("file") MultipartFile fil
@Hidden
@PostMapping("{type}/json")
@Operation(summary = "Get JSON for a type of DDI item", description = "Get a JSON list of item for a type of DDI items .")
public ResponseEntity<?> ByType (
public ResponseEntity<?> byType(
@PathVariable("type") DDIItemType type)
throws IOException, ExceptionColecticaUnreachable {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package fr.insee.rmes.metadata.client;

import java.util.List;

import fr.insee.rmes.metadata.exceptions.ExceptionColecticaUnreachable;
import fr.insee.rmes.metadata.model.ColecticaItem;
import fr.insee.rmes.metadata.model.ColecticaItemPostRef;
import fr.insee.rmes.metadata.model.ColecticaItemPostRefList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.http.entity.ContentType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@ApiResponse(responseCode = "500", description = "Internal server error") })
public class MetadataController {

final static Logger log = LogManager.getLogger(MetadataController.class);
static final Logger log = LogManager.getLogger(MetadataController.class);

@Autowired
private MetadataService metadataService;
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/fr/insee/rmes/metadata/model/ObjectColecticaPost.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ public class ObjectColecticaPost {
*/

@JsonProperty("ItemTypes")
private List<String> ItemTypes;
private List<String> itemTypes;

@JsonProperty("TargetItem")
private TargetItem targetItem;

@JsonProperty("UseDistinctResultItem")
private Boolean UseDistinctResultItem;
private Boolean useDistinctResultItem;

@JsonProperty("UseDistinctTargetItem")
private Boolean UseDistinctTargetItem;
private Boolean useDistinctTargetItem;

public List<String> getItemTypes() {
return ItemTypes;
return itemTypes;
}

public void setItemTypes(List<String> itemTypes) {
ItemTypes = itemTypes;
this.itemTypes = itemTypes;
}

public TargetItem getTargetItem() {
Expand All @@ -43,25 +43,25 @@ public void setTargetItem(TargetItem targetItem) {
}

public Boolean getUseDistinctResultItem() {
return UseDistinctResultItem;
return useDistinctResultItem;
}

public void setUseDistinctResultItem(Boolean useDistinctResultItem) {
UseDistinctResultItem = useDistinctResultItem;
this.useDistinctResultItem = useDistinctResultItem;
}

public Boolean getUseDistinctTargetItem() {
return UseDistinctTargetItem;
return useDistinctTargetItem;
}

public void setUseDistinctTargetItem(Boolean useDistinctTargetItem) {
UseDistinctTargetItem = useDistinctTargetItem;
this.useDistinctTargetItem = useDistinctTargetItem;
}

@Override
public String toString() {
return "RelationshipPost [ItemTypes=" + ItemTypes + ", targetItem=" + targetItem + ", UseDistinctResultItem="
+ UseDistinctResultItem + ", UseDistinctTargetItem=" + UseDistinctTargetItem + "]";
return "RelationshipPost [ItemTypes=" + itemTypes + ", targetItem=" + targetItem + ", UseDistinctResultItem="
+ useDistinctResultItem + ", UseDistinctTargetItem=" + useDistinctTargetItem + "]";
}

public String toJson() throws JsonProcessingException {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/fr/insee/rmes/metadata/model/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Options {
private Object versionRationale = new Object();

@JsonProperty("SetName")
private String SetName = "";
private String setName = "";

public Object getVersionRationale() {
return versionRationale;
Expand All @@ -19,16 +19,16 @@ public void setVersionRationale(Object versionReversionRationale) {
}

public String getSetName() {
return SetName;
return setName;
}

public void setSetName(String setName) {
SetName = setName;
this.setName = setName;
}

@Override
public String toString() {
return "Options [versionReversionRationale=" + versionRationale + ", SetName=" + SetName + "]";
return "Options [versionReversionRationale=" + versionRationale + ", SetName=" + setName + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import fr.insee.rmes.metadata.model.Relationship;
import fr.insee.rmes.metadata.model.ColecticaItem;
import fr.insee.rmes.metadata.model.ColecticaItemRef;
import fr.insee.rmes.metadata.model.ObjectColecticaPost;
import fr.insee.rmes.metadata.model.Unit;
import fr.insee.rmes.search.model.DDIItemType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
@Service
@Slf4j
public class MetadataServiceItemImpl implements MetadataServiceItem {
private final static String NAME_FRAGMENT = "//*[local-name()='Fragment']";
private final static String TEXT_ID = ".//*[local-name()='ID']/text()";
private static final String NAME_FRAGMENT = "//*[local-name()='Fragment']";
private static final String TEXT_ID = ".//*[local-name()='ID']/text()";
@Autowired
MetadataRepository metadataRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ private String itemToString(ColecticaItem colecticaItem) throws Exception {
private Node getNodeByXpath(DDIDocumentBuilder docBuilder, ColecticaItem ddiInstance, String xpathExpression)
throws Exception {
String fragment = xpathProcessor.queryString(ddiInstance.getItem(), xpathExpression);
Node node = DocumentBuilderUtils.getNode(fragment.trim(), docBuilder);
return node;
return DocumentBuilderUtils.getNode(fragment.trim(), docBuilder);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@ApiResponse(responseCode = "500", description = "Internal server error") })
public class DDISearch {

final static Logger log = LogManager.getLogger(DDISearch.class);
static final Logger log = LogManager.getLogger(DDISearch.class);

@Autowired
SearchService searchService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@
@RestController
@Hidden
public class ElasticsearchController {
private final static String HTTPS = "https://";
private final static String HTTP = "http://";
private final static String AUTHORIZATION = "Authorization";
private final static String BASIC = "Basic ";
private final static String KBN = "kbn-xsrf";
private final static String REPORTING = "reporting";
private final static String ERREUR_ES = "Une erreur s'est produite lors de la requête Elasticsearch.";
private final static String SEARCH = "/_search";
private final static String CONTENT_TYPE = "Content-Type";
private final static String APPLI_JSON = "application/json";
private static final String HTTPS = "https://";
private static final String HTTP = "http://";
private static final String AUTHORIZATION = "Authorization";
private static final String BASIC = "Basic ";
private static final String KBN = "kbn-xsrf";
private static final String REPORTING = "reporting";
private static final String ERREUR_ES = "Une erreur s'est produite lors de la requête Elasticsearch.";
private static final String SEARCH = "/_search";
private static final String CONTENT_TYPE = "Content-Type";
private static final String APPLI_JSON = "application/json";

@Value("${fr.insee.rmes.elasticsearch.host}")
private String elasticHost;
Expand All @@ -71,7 +71,7 @@ public class ElasticsearchController {
private final ElasticsearchClient elasticsearchClient;


final static Logger logger = LogManager.getLogger(ElasticsearchController.class);
static final Logger logger = LogManager.getLogger(ElasticsearchController.class);


@Autowired
Expand Down Expand Up @@ -184,7 +184,7 @@ public ResponseEntity<?> searchElastic() {
}

@PostMapping("/search/elastic/matchType/{type}")
public ResponseEntity<?> ByType(
public ResponseEntity<?> byType(
@PathVariable ("type") DDIItemType type
) {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONObject;
Expand All @@ -17,14 +16,13 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.text.html.parser.Entity;

@RestController
@RequestMapping("/env")
@Tag(name = "RMeS Environment")
public class RMeSEnvironment {

private final static Logger log = LogManager.getLogger(fr.insee.rmes.webservice.rest.RMeSEnvironment.class);
private static final Logger log = LogManager.getLogger(fr.insee.rmes.webservice.rest.RMeSEnvironment.class);

@Autowired
Environment env;
Expand Down

0 comments on commit 9c0b026

Please sign in to comment.