All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.java.ServiceGrpcServerInsertImpl.template Maven / Gradle / Ivy

The newest version!

        @Override
        public void @service_name@(WriteBase writer, AbstractBackendController.ReqRes<@service_request@, @service_response@> reqres,
        List> prevSteps, ServiceContext context) {

        @service_request@ request = reqres.request;
        @[email protected] replyB = null;
        try {
            Object[] paramValues = null;
            @paramValues@

            String sqlStmt = SqlStmts.@service_name@;
            @sqlreplace@

            if (null == writer) writer = new WriteBase();
            int recordsAdded = writer.execute(sqlStmt, paramValues );
            String recordId = (null == writer.lastGeneratedKey ) ? "" : writer.lastGeneratedKey;
            replyB = @[email protected]().setStatus(OK).setRecordId(recordId).setCount(recordsAdded);


        } catch (SQLException ex) {
            LOG.info("ERROR while processing @service_name@", ex);
            replyB = @[email protected]().setStatus(
                Status.newBuilder().setStatus(StatusCode.DB_FAILURE).addErrorMessages(ex.getMessage()).build());
            if (BackendControllerFactory.getInstance().pipelines != null) {
                for (AbstractBackendController pipeline : BackendControllerFactory.getInstance().pipelines)
                    pipeline.onError@service_name@(reqres, prevSteps, context, ex);
            }
        } catch (Exception ex) {
            LOG.warn("ERROR while processing @service_name@", ex);
            replyB = @[email protected]().setStatus(
                Status.newBuilder().setStatus(StatusCode.UNKNOWN_ERROR).addErrorMessages(ex.getMessage()).build());
            if (BackendControllerFactory.getInstance().pipelines != null) {
                for (AbstractBackendController pipeline : BackendControllerFactory.getInstance().pipelines)
                    pipeline.onError@service_name@(reqres, prevSteps, context, ex);
            }

        }
        if ( null != replyB) reqres.response = replyB.build();
    }

    @Override
    public void @service_name@Bulk(WriteBase writer, AbstractBackendController.ReqRes reqres,
        List> prevSteps, ServiceContext context) {


        try {
            Bulk@[email protected] replyB = null;

            int recordT = reqres.request.getRequestsCount();
            List records = new ArrayList<>(recordT + 1);
            for ( int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy