se soluciono un error donde Asset era un .Java en lugar de un .java

This commit is contained in:
lucas bonfil 2024-08-21 13:49:15 -03:00
parent 7649753506
commit 97d1c87af5
6 changed files with 27 additions and 24 deletions

View file

@ -8,10 +8,10 @@
plugins { plugins {
// Apply the application plugin to add support for building a CLI application. // Apply the application plugin to add support for building a CLI application.
id 'application' id 'application'
} }
ext { ext {
javaMainClass = "application.java.App" javaMainClass = "application.java.App"
} }
repositories { repositories {
@ -30,16 +30,14 @@ java {
languageVersion = JavaLanguageVersion.of(11) languageVersion = JavaLanguageVersion.of(11)
} }
} }
sourceSets { sourceSets {
main { main {
java { java {
srcDirs = ['application-gateway-java/src/main/java'] srcDirs = ['src/main/java']
} }
} }
} }
application { application {
// Define the main class for the application. mainClass = 'application.java.App'
mainClass = 'App'
} }

View file

@ -134,7 +134,7 @@ public final class App {
// Update an asset which does not exist. // Update an asset which does not exist.
updateNonExistentAsset(); updateNonExistentAsset();
} }
/** /**
* This type of transaction would typically only be run once by an application * This type of transaction would typically only be run once by an application
* the first time it was started after its initial deployment. A new version of * the first time it was started after its initial deployment. A new version of
@ -155,7 +155,7 @@ public final class App {
System.out.println("\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger"); System.out.println("\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger");
var result = contract.evaluateTransaction("GetAllAssets"); var result = contract.evaluateTransaction("GetAllAssets");
System.out.println("*** Result: " + prettyJson(result)); System.out.println("*** Result: " + prettyJson(result));
} }
@ -191,7 +191,7 @@ public final class App {
"12345678", "12345678",
LocalDate.now(), LocalDate.now(),
30, 30,
LocalDate.now() LocalDate.now()
); );
contract.submitTransaction( contract.submitTransaction(
@ -242,7 +242,7 @@ public final class App {
throw new RuntimeException("Transaction " + status.getTransactionId() + throw new RuntimeException("Transaction " + status.getTransactionId() +
" failed to commit with status code " + status.getCode()); " failed to commit with status code " + status.getCode());
} }
System.out.println("*** Transaction committed successfully"); System.out.println("*** Transaction committed successfully");
} }
@ -250,7 +250,7 @@ public final class App {
System.out.println("\n--> Evaluate Transaction: ReadAsset, function returns asset attributes"); System.out.println("\n--> Evaluate Transaction: ReadAsset, function returns asset attributes");
var evaluateResult = contract.evaluateTransaction("ReadAsset", assetId); var evaluateResult = contract.evaluateTransaction("ReadAsset", assetId);
System.out.println("*** Result:" + prettyJson(evaluateResult)); System.out.println("*** Result:" + prettyJson(evaluateResult));
} }
@ -261,7 +261,7 @@ public final class App {
private void updateNonExistentAsset() { private void updateNonExistentAsset() {
try { try {
System.out.println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error"); System.out.println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error");
Asset asset = new Asset( Asset asset = new Asset(
"asset70", // Asset ID "asset70", // Asset ID
"Tomoko", // Owner "Tomoko", // Owner
@ -300,7 +300,7 @@ public final class App {
Integer.toString(asset.getCantidad()), Integer.toString(asset.getCantidad()),
asset.getExpectedSupplyDuration().toString() asset.getExpectedSupplyDuration().toString()
); );
System.out.println("******** FAILED to return an error"); System.out.println("******** FAILED to return an error");
} catch (EndorseException | SubmitException | CommitStatusException e) { } catch (EndorseException | SubmitException | CommitStatusException e) {
System.out.println("*** Successfully caught the error: "); System.out.println("*** Successfully caught the error: ");

View file

@ -1,6 +1,6 @@
package models; package models;
class Asset { public class Asset {
private String id; private String id;
private String owner; private String owner;
private String prescripcionAnteriorId; private String prescripcionAnteriorId;
@ -57,4 +57,4 @@ class Asset {
public LocalDate getFechaDeAutorizacion() { return fechaDeAutorizacion; } public LocalDate getFechaDeAutorizacion() { return fechaDeAutorizacion; }
public int getCantidad() { return cantidad; } public int getCantidad() { return cantidad; }
public LocalDate getExpectedSupplyDuration() { return expectedSupplyDuration; } public LocalDate getExpectedSupplyDuration() { return expectedSupplyDuration; }
} }

View file

@ -1,7 +1,7 @@
package com.code.hyperledger; package com.code.hyperledger;
//import com.code.hyperledger.coso.Asset; import com.code.hyperledger.coso.Asset;
import org.hyperledger.fabric.gateway.*; import org.hyperledger.fabric.gateway.*;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -179,7 +179,7 @@ public final class App {
private void createAsset() throws EndorseException, SubmitException, CommitStatusException, CommitException { private void createAsset() throws EndorseException, SubmitException, CommitStatusException, CommitException {
System.out.println("\n--> Submit Transaction: CreateAsset, creates new asset with all arguments"); System.out.println("\n--> Submit Transaction: CreateAsset, creates new asset with all arguments");
/*Asset asset = new Asset( Asset asset = new Asset(
assetId, assetId,
"Tom", "Tom",
"presc456", "presc456",
@ -216,7 +216,7 @@ public final class App {
asset.getFechaDeAutorizacion().toString(), asset.getFechaDeAutorizacion().toString(),
Integer.toString(asset.getCantidad()), Integer.toString(asset.getCantidad()),
asset.getExpectedSupplyDuration().toString() asset.getExpectedSupplyDuration().toString()
);*/ );
System.out.println("*** Transaction committed successfully"); System.out.println("*** Transaction committed successfully");
} }
@ -263,10 +263,10 @@ public final class App {
* responses from the smart contract. * responses from the smart contract.
*/ */
private void updateNonExistentAsset() { private void updateNonExistentAsset() {
//try { try {
System.out.println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error"); System.out.println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error");
/*Asset asset = new Asset( Asset asset = new Asset(
"asset70", // Asset ID "asset70", // Asset ID
"Tomoko", // Owner "Tomoko", // Owner
"presc789", // Prescripcion Anterior Id "presc789", // Prescripcion Anterior Id
@ -324,6 +324,6 @@ public final class App {
e.printStackTrace(System.out); e.printStackTrace(System.out);
System.out.println("Transaction ID: " + e.getTransactionId()); System.out.println("Transaction ID: " + e.getTransactionId());
System.out.println("Status code: " + e.getCode()); System.out.println("Status code: " + e.getCode());
}*/ }
} }
} }

View file

@ -1,5 +1,6 @@
package com.code.main.controllers; package com.code.hyperledger.controllers;
import com.code.hyperledger.coso.Asset;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -8,6 +9,8 @@ public class Example {
@GetMapping("/hello") @GetMapping("/hello")
public String sayHello() { public String sayHello() {
Asset asset = new Asset();
return "Hello, World!"; return "Hello, World!";
} }
} }

View file

@ -5,9 +5,11 @@ import java.time.LocalDateTime;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
public class Asset { public class Asset {
private String id; private String id;
private String owner; private String owner;
@ -26,4 +28,4 @@ public class Asset {
private int cantidad; private int cantidad;
private LocalDate expectedSupplyDuration; private LocalDate expectedSupplyDuration;
} }