Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ForecastControllers #591

Merged
merged 10 commits into from
Apr 9, 2024
2 changes: 2 additions & 0 deletions cwms-data-api/src/main/java/cwms/cda/api/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public final class Controllers {
public static final String STANDARD_TEXT_ID = "standard-text-id";
public static final String TRIM = "trim";

public static final String FORECAST_SPEC = "forecast-spec";


static {
JavalinValidation.register(JooqDao.DeleteMethod.class, Controllers::getDeleteMethod);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cwms.cda.api;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.data.dao.JooqDao;
import io.javalin.apibuilder.CrudHandler;
import io.javalin.http.Context;
import io.javalin.plugin.openapi.annotations.OpenApi;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;
import java.util.logging.Logger;

import static com.codahale.metrics.MetricRegistry.name;
import static cwms.cda.api.Controllers.RESULTS;
import static cwms.cda.api.Controllers.SIZE;

public class ForecastInstanceController implements CrudHandler {
private static final Logger logger = Logger.getLogger(ForecastInstanceController.class.getName());

public static final String TAG = "ForecastInstance";
private final MetricRegistry metrics;

private final Histogram requestResultSize;

public ForecastInstanceController(MetricRegistry metrics) {
this.metrics = metrics;
String className = this.getClass().getName();
requestResultSize = this.metrics.histogram((name(className, RESULTS, SIZE)));
}

private Timer.Context markAndTime(String subject) {
return Controllers.markAndTime(metrics, getClass().getName(), subject);
}

@OpenApi(ignore = true)
@Override
public void create(@NotNull Context ctx) {

}

protected DSLContext getDslContext(Context ctx) {
return JooqDao.getDslContext(ctx);
}

@OpenApi(ignore = true)
@Override
public void delete(@NotNull Context ctx, @NotNull String forecastSpecId) {

}

@OpenApi(ignore = true)
@Override
public void getAll(@NotNull Context ctx) {

}

@OpenApi(ignore = true)
@Override
public void getOne(@NotNull Context ctx, @NotNull String id) {

}

@OpenApi(ignore = true)
@Override
public void update(@NotNull Context ctx, @NotNull String id) {


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cwms.cda.api;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.data.dao.JooqDao;
import io.javalin.apibuilder.CrudHandler;
import io.javalin.http.Context;
import io.javalin.plugin.openapi.annotations.OpenApi;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;
import java.util.logging.Logger;

import static com.codahale.metrics.MetricRegistry.name;
import static cwms.cda.api.Controllers.RESULTS;
import static cwms.cda.api.Controllers.SIZE;

public class ForecastSpecController implements CrudHandler {
private static final Logger logger = Logger.getLogger(ForecastSpecController.class.getName());

public static final String TAG = "ForecastSpec";
private final MetricRegistry metrics;

private final Histogram requestResultSize;

public ForecastSpecController(MetricRegistry metrics) {
this.metrics = metrics;
String className = this.getClass().getName();
requestResultSize = this.metrics.histogram((name(className, RESULTS, SIZE)));
}

private Timer.Context markAndTime(String subject) {
return Controllers.markAndTime(metrics, getClass().getName(), subject);
}

@OpenApi(ignore = true)
@Override
public void create(@NotNull Context ctx) {

}

protected DSLContext getDslContext(Context ctx) {
return JooqDao.getDslContext(ctx);
}

@OpenApi(ignore = true)
@Override
public void delete(@NotNull Context ctx, @NotNull String forecastSpecId) {

}

@OpenApi(ignore = true)
@Override
public void getAll(@NotNull Context ctx) {

}

@OpenApi(ignore = true)
@Override
public void getOne(@NotNull Context ctx, @NotNull String id) {

}

@OpenApi(ignore = true)
@Override
public void update(@NotNull Context ctx, @NotNull String id) {


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package cwms.cda.api;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.data.dao.JooqDao;
import io.javalin.apibuilder.CrudHandler;
import io.javalin.http.Context;
import io.javalin.plugin.openapi.annotations.OpenApi;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;
import java.util.logging.Logger;

import static com.codahale.metrics.MetricRegistry.name;
import static cwms.cda.api.Controllers.RESULTS;
import static cwms.cda.api.Controllers.SIZE;

public class ForecastTimeseriesController implements CrudHandler {
private static final Logger logger = Logger.getLogger(ForecastSpecController.class.getName());

public static final String TAG = "ForecastTimeseries";
adamkorynta marked this conversation as resolved.
Show resolved Hide resolved
private final MetricRegistry metrics;

private final Histogram requestResultSize;

public ForecastTimeseriesController(MetricRegistry metrics) {
this.metrics = metrics;
String className = this.getClass().getName();
requestResultSize = this.metrics.histogram((name(className, RESULTS, SIZE)));
}

private Timer.Context markAndTime(String subject) {
return Controllers.markAndTime(metrics, getClass().getName(), subject);
}

@OpenApi(ignore = true)
@Override
public void create(@NotNull Context ctx) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm re-thinking how this create would work.

Workflow:

client creates a spec, providing a list of time series ids
client creates an instance for a spec when going to run a forecast
client posts the results for the list of time series associated with the spec. -> isn't this just the time series controller? the spec is already associated with the time series identifier and the instance is already associated with the values given the forecast date and the time series id. What extra logic is needed by CDA to tie the time series storage to the instance?

Similarly for the delete, any interactions would be in the existing timeseries controller.


}

protected DSLContext getDslContext(Context ctx) {
return JooqDao.getDslContext(ctx);
}

@OpenApi(ignore = true)
@Override
public void delete(@NotNull Context ctx, @NotNull String forecastSpecId) {

}

@OpenApi(ignore = true)
@Override
public void getAll(@NotNull Context ctx) {

}

@OpenApi(ignore = true)
@Override
public void getOne(@NotNull Context ctx, @NotNull String id) {

}

@OpenApi(ignore = true)
@Override
public void update(@NotNull Context ctx, @NotNull String id) {
adamkorynta marked this conversation as resolved.
Show resolved Hide resolved


}

}