Search in sources :

Example 6 with FirestoreProtoClient

use of com.google.startupos.common.firestore.FirestoreProtoClient in project startup-os by google.

the class CiTaskTool method run.

void run() {
    client = new FirestoreProtoClient(authService.getProjectId(), authService.getToken());
    int id = 100;
    client.setProtoDocument(ReviewerConstants.CI_REQUESTS_PATH + "/" + id, CiRequest.newBuilder().setDiffId(id).addTarget(Target.newBuilder().setRepo(Repo.newBuilder().setId("startup-os").setUrl("https://github.com/google/startup-os").build()).setCommitId("5b599dd74f58ff5716520db5f724fdf7a75ca419").build()).build());
    System.exit(0);
}
Also used : FirestoreProtoClient(com.google.startupos.common.firestore.FirestoreProtoClient)

Example 7 with FirestoreProtoClient

use of com.google.startupos.common.firestore.FirestoreProtoClient in project startup-os by google.

the class CodeReviewService method getDiff.

@Override
public void getDiff(DiffRequest request, StreamObserver<Protos.Diff> responseObserver) {
    checkAuth();
    FirestoreProtoClient client = new FirestoreProtoClient(authService.getProjectId(), authService.getToken());
    Diff diff = (Diff) client.getProtoDocument(ReviewerConstants.DIFF_COLLECTION, String.valueOf(request.getDiffId()), Diff.newBuilder());
    responseObserver.onNext(diff);
    responseObserver.onCompleted();
}
Also used : Diff(com.google.startupos.tools.reviewer.local_server.service.Protos.Diff) TextDiff(com.google.startupos.common.Protos.TextDiff) FirestoreProtoClient(com.google.startupos.common.firestore.FirestoreProtoClient)

Example 8 with FirestoreProtoClient

use of com.google.startupos.common.firestore.FirestoreProtoClient in project startup-os by google.

the class CodeReviewService method getAvailableDiffNumber.

// TODO: fix concurrency issues (if two different call method at same time)
// could be done by wrapping in a transaction
@Override
public void getAvailableDiffNumber(Empty request, StreamObserver<DiffNumberResponse> responseObserver) {
    checkAuth();
    FirestoreProtoClient client = new FirestoreProtoClient(authService.getProjectId(), authService.getToken());
    try {
        DiffNumberResponse diffNumberResponse = (DiffNumberResponse) client.getProtoDocument(ReviewerConstants.LAST_DIFF_NUMBER_DOCUMENT, DiffNumberResponse.newBuilder());
        diffNumberResponse = diffNumberResponse.toBuilder().setLastDiffId(diffNumberResponse.getLastDiffId() + 1).build();
        client.setProtoDocument(ReviewerConstants.LAST_DIFF_NUMBER_DOCUMENT, diffNumberResponse);
        responseObserver.onNext(diffNumberResponse);
    } catch (Exception e) {
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        throw e;
    }
    responseObserver.onCompleted();
}
Also used : StringWriter(java.io.StringWriter) FirestoreProtoClient(com.google.startupos.common.firestore.FirestoreProtoClient) IOException(java.io.IOException) DiffNumberResponse(com.google.startupos.tools.reviewer.local_server.service.Protos.DiffNumberResponse) PrintWriter(java.io.PrintWriter)

Aggregations

FirestoreProtoClient (com.google.startupos.common.firestore.FirestoreProtoClient)8 IOException (java.io.IOException)3 TextDiff (com.google.startupos.common.Protos.TextDiff)2 Diff (com.google.startupos.tools.reviewer.local_server.service.Protos.Diff)2 ReviewerConfig (com.google.startupos.tools.reviewer.ReviewerProtos.ReviewerConfig)1 InitCommand (com.google.startupos.tools.reviewer.aa.commands.InitCommand)1 ReviewerMetadataUpdaterTask (com.google.startupos.tools.reviewer.job.tasks.ReviewerMetadataUpdaterTask)1 LocalServer (com.google.startupos.tools.reviewer.local_server.LocalServer)1 CodeReviewService (com.google.startupos.tools.reviewer.local_server.service.CodeReviewService)1 DiffNumberResponse (com.google.startupos.tools.reviewer.local_server.service.Protos.DiffNumberResponse)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1