Skip to content

Commit

Permalink
Merge pull request #20 from nimble-platform/staging
Browse files Browse the repository at this point in the history
Pull Request for Release 13.0.0
  • Loading branch information
dileepajayakody authored Oct 1, 2019
2 parents 55b95c2 + 57e2743 commit 8e4d5ad
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@
<artifactId>utility</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.nimble.core.common</groupId>
<artifactId>ubl-data-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<!--logstash dependencies-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import eu.nimble.indexing.service.IdentityService;
import eu.nimble.indexing.utils.SearchEvent;
import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter;
import eu.nimble.utility.LoggerUtils;
import io.swagger.annotations.*;
import org.slf4j.Logger;
Expand Down Expand Up @@ -493,6 +494,49 @@ public ResponseEntity<?> setParty(
return ResponseEntity.ok(Boolean.TRUE);
}

@ApiOperation(value = "", notes = "Reindex Party With Trust Updates", response = SearchResult.class)
@PostMapping("/party/trust")
public ResponseEntity<?> partyTrustUpdate(
@RequestParam(name = "partyId") String partyId,
@RequestBody eu.nimble.service.model.ubl.commonaggregatecomponents.PartyType partyType,
@RequestHeader(value = "Authorization") String bearerToken) throws Exception {

if (identityService.hasAnyRole(bearerToken, PLATFORM_MANAGER,LEGAL_REPRESENTATIVE,NIMBLE_USER,
PUBLISHER,COMPANY_ADMIN,EFACTORYUSER) == false)
return new ResponseEntity<>("User Not Allowed To Access The Indexing End Points", HttpStatus.UNAUTHORIZED);


if (partyId.equals("null")) {
return ResponseEntity.ok(PartyTypeUtils.template());
}

Optional<PartyType> res = partyService.get(partyId);
PartyType indexParty = res.get();

// get trust scores
partyType.getQualityIndicator().forEach(qualityIndicator -> {
if(qualityIndicator.getQualityParameter() != null && qualityIndicator.getQuantity() != null) {
if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.COMPANY_RATING.toString())) {
indexParty.setTrustRating(qualityIndicator.getQuantity().getValue().doubleValue());
} else if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.TRUST_SCORE.toString())) {
indexParty.setTrustScore(qualityIndicator.getQuantity().getValue().doubleValue());
} else if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.DELIVERY_PACKAGING.toString())) {
indexParty.setTrustDeliveryPackaging(qualityIndicator.getQuantity().getValue().doubleValue());
} else if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.FULFILLMENT_OF_TERMS.toString())) {
indexParty.setTrustFullfillmentOfTerms(qualityIndicator.getQuantity().getValue().doubleValue());
} else if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.SELLER_COMMUNICATION.toString())) {
indexParty.setTrustSellerCommunication(qualityIndicator.getQuantity().getValue().doubleValue());
} else if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.NUMBER_OF_TRANSACTIONS.toString())) {
indexParty.setTrustNumberOfTransactions(qualityIndicator.getQuantity().getValue().doubleValue());
} else if(qualityIndicator.getQualityParameter().contentEquals(QualityIndicatorParameter.TRADING_VOLUME.toString())) {
indexParty.setTrustTradingVolume(qualityIndicator.getQuantity().getValue().doubleValue());
}
}
});
partyService.set(indexParty);
return ResponseEntity.ok(Boolean.TRUE);
}

@ApiOperation(value = "", notes = "Retrieve specific fields of property index", response = IndexField.class,
responseContainer = "List")
@GetMapping("/property/fields")
Expand Down

0 comments on commit 8e4d5ad

Please sign in to comment.