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

View file

@ -134,7 +134,7 @@ public final class App {
// Update an asset which does not exist.
updateNonExistentAsset();
}
/**
* 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
@ -155,7 +155,7 @@ public final class App {
System.out.println("\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger");
var result = contract.evaluateTransaction("GetAllAssets");
System.out.println("*** Result: " + prettyJson(result));
}
@ -191,7 +191,7 @@ public final class App {
"12345678",
LocalDate.now(),
30,
LocalDate.now()
LocalDate.now()
);
contract.submitTransaction(
@ -242,7 +242,7 @@ public final class App {
throw new RuntimeException("Transaction " + status.getTransactionId() +
" failed to commit with status code " + status.getCode());
}
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");
var evaluateResult = contract.evaluateTransaction("ReadAsset", assetId);
System.out.println("*** Result:" + prettyJson(evaluateResult));
}
@ -261,7 +261,7 @@ public final class App {
private void updateNonExistentAsset() {
try {
System.out.println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error");
Asset asset = new Asset(
"asset70", // Asset ID
"Tomoko", // Owner
@ -300,7 +300,7 @@ public final class App {
Integer.toString(asset.getCantidad()),
asset.getExpectedSupplyDuration().toString()
);
System.out.println("******** FAILED to return an error");
} catch (EndorseException | SubmitException | CommitStatusException e) {
System.out.println("*** Successfully caught the error: ");

View file

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

View file

@ -1,7 +1,7 @@
package com.code.hyperledger;
//import com.code.hyperledger.coso.Asset;
import com.code.hyperledger.coso.Asset;
import org.hyperledger.fabric.gateway.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -179,7 +179,7 @@ public final class App {
private void createAsset() throws EndorseException, SubmitException, CommitStatusException, CommitException {
System.out.println("\n--> Submit Transaction: CreateAsset, creates new asset with all arguments");
/*Asset asset = new Asset(
Asset asset = new Asset(
assetId,
"Tom",
"presc456",
@ -216,7 +216,7 @@ public final class App {
asset.getFechaDeAutorizacion().toString(),
Integer.toString(asset.getCantidad()),
asset.getExpectedSupplyDuration().toString()
);*/
);
System.out.println("*** Transaction committed successfully");
}
@ -263,10 +263,10 @@ public final class App {
* responses from the smart contract.
*/
private void updateNonExistentAsset() {
//try {
try {
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
"Tomoko", // Owner
"presc789", // Prescripcion Anterior Id
@ -324,6 +324,6 @@ public final class App {
e.printStackTrace(System.out);
System.out.println("Transaction ID: " + e.getTransactionId());
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.RestController;
@ -8,6 +9,8 @@ public class Example {
@GetMapping("/hello")
public String sayHello() {
Asset asset = new Asset();
return "Hello, World!";
}
}
}

View file

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