@Override public Class<T> getType() { return model.getKind().getModelClass(); } };
public String getName() { return value.getName(); } }
@Override public ListResult<T> apply(ListResult<T> result) { List<T> list = new ArrayList<>(result.getItems()); if (delegate != null) { // We are sorting inline when a delegate is given. Otherwise its a no-op list.sort(this); } return new ListResult.Builder<T>().createFrom(result).items(list).build(); }
@Override public ListResult<Integration> apply(ListResult<Integration> list) { List<Integration> filtered = list.getItems().stream() .filter(i -> !i.isDeleted()) .collect(Collectors.toList()); return new ListResult.Builder<Integration>() .totalCount(filtered.size()) .addAllItems(filtered).build(); } }
private <T extends WithId<T>> void importModels(JsonDbDao<T> export, ArrayList<ChangeEvent> result) { for (T item : export.fetchAll().getItems()) { Kind kind = item.getKind(); String id = item.getId().get(); if (dataManager.fetch(export.getType(), id) == null) { dataManager.create(item); if( kind == Kind.Connection ) { connectionHandler.updateBulletinBoard(id); } result.add(ChangeEvent.of("created", kind.getModelName(), id)); } } }
private DataShape dataShape(DataShapeKinds kind, String type) { return new DataShape.Builder().kind(kind).type(type).build(); } }
private static DataShape createShapeFromReference(final String specification, final String title, final String reference) { final String jsonSchema = JsonSchemaHelper.resolveSchemaForReference(specification, title, reference); return new DataShape.Builder().kind("json-schema").specification(jsonSchema).build(); }
@Override public DataShape createShapeFromResponse(final String specification, final Swagger swagger, final Operation operation) { final Optional<Response> maybeResponse = findResponse(operation); if (!maybeResponse.isPresent()) { return DATA_SHAPE_NONE; } final DataShape response = createShapeFromProperty(specification, maybeResponse.get().getSchema()); if (response.getKind() == DataShapeKinds.NONE) { return response; } return new DataShape.Builder().createFrom(response).name("Response").description("API response payload").build(); }
default void deleteAll() { ListResult<T> l = fetchAll(); for (T entity : l.getItems()) { delete(entity); } }
public String getCollectionPath() { return "/"+Kind.from(getType()).getModelName()+"s"; }
public <T extends WithId<T>> void store(ModelData<T> modelData) { try { final Kind kind = modelData.getKind(); final T entity = modelData.getData(); LOGGER.debug("{}:{}", kind, modelData.getDataAsJson()); store(entity, kind.getModelClass()); } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) { LOGGER.warn("Cannot load entity from file: ", e); throw SyndesisServerException.launderThrowable(e); } }
public void clearCache() { for (Kind kind : Kind.values()) { caches.getCache(kind.modelName).clear(); } }
@Override public ListResult<T> apply(ListResult<T> result) { List<T> list = result.getItems().stream().filter(filter).collect(Collectors.toList()); return new ListResult.Builder<T>().createFrom(result).items(list).totalCount(list.size()).build(); }
private DataShape dataShape(String kind, String type) { return new DataShape.Builder().kind(kind).type(type).build(); } }
private static DataShape createShapeFromReference(final String specification, final String title, final String reference) { final String jsonSchema = JsonSchemaHelper.resolveSchemaForReference(specification, title, reference); return new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).specification(jsonSchema).build(); }
@Override public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() { ListResult<IntegrationMetricsSummary> integrationMetricsList = dataMgr.fetchAll( IntegrationMetricsSummary.class); return rollup(integrationMetricsList.getItems()); }
public String getCollectionPath() { return "/"+Kind.from(getType()).getModelName()+"s"; }
/** * Applies the filter to the provided list. * * @param result The result to filter. * @return The relevant page of the provided list. Returns an empty list if the requested page would be outside of the provided list range. */ @Override public ListResult<T> apply(ListResult<T> result) { List<T> list = result.getItems(); if (startIndex >= list.size()) { list = Collections.emptyList(); } else { list = list.subList(startIndex, Math.min(list.size(), endIndex)); } return new ListResult.Builder<T>().createFrom(result).items(list).build(); }
/** * Applies the filter to the provided list. * * @param result The result to filter. * @return all entries with ids that start with specified prefix */ @Override public ListResult<T> apply(ListResult<T> result) { List<T> list = result.getItems().stream() .filter(x -> x.getId().filter(y->y.startsWith(prefix)).isPresent() ) .collect(Collectors.toList()); return new ListResult.Builder<T>().createFrom(result).items(list).build(); }