use of javax.validation.constraints.NotNull in project SpinalTap by airbnb.
the class MysqlSchemaTracker method processDDLStatement.
public void processDDLStatement(@NotNull final QueryEvent event) {
BinlogFilePos binlogFilePos = event.getBinlogFilePos();
String ddl = event.getSql();
if (schemaStore.get(binlogFilePos) != null) {
log.info(String.format("DDL Statement (%s) has already been processed. (BinlogFilePos: %s)", ddl, binlogFilePos));
return;
}
// It could be a new database which has not been created in schema store database, so don't
// switch to any database before applying database DDL.
schemaDatabase.applyDDLStatement(DATABASE_DDL_SQL_PATTERN.matcher(ddl).find() ? "" : event.getDatabase(), ddl);
// Get schemas for active tables in schema store
Table<String, String, MysqlTableSchema> activeTableSchemasInStore = Tables.newCustomTable(Maps.newHashMap(), Maps::newHashMap);
schemaStore.getAll().values().stream().map(treeMap -> treeMap.lastEntry().getValue()).filter(schema -> !schema.getColumnInfo().isEmpty()).forEach(schema -> activeTableSchemasInStore.put(schema.getDatabase(), schema.getTable(), schema));
Set<String> activeDatabasesInStore = activeTableSchemasInStore.rowKeySet();
Set<String> databasesInSchemaDatabase = schemaDatabase.listDatabases();
// Handle new databases
Sets.difference(databasesInSchemaDatabase, activeDatabasesInStore).forEach(newDatabase -> updateSchemaStore(newDatabase, event, Maps.newHashMap(), schemaDatabase.fetchTableSchema(newDatabase)));
// Handle existing databases
activeDatabasesInStore.forEach(database -> updateSchemaStore(database, event, activeTableSchemasInStore.row(database), schemaDatabase.fetchTableSchema(database)));
}
use of javax.validation.constraints.NotNull in project actframework by actframework.
the class FindBy method initialized.
@Override
protected void initialized() {
App app = App.instance();
rawType = spec.rawType();
notNull = spec.hasAnnotation(NotNull.class);
findOne = !(Iterable.class.isAssignableFrom(rawType));
dao = app.dbServiceManager().dao(findOne ? rawType : (Class) spec.typeParams().get(0));
queryFieldName = S.string(options.get("field"));
byId = findOne && S.blank(queryFieldName) && (Boolean) options.get("byId");
resolver = app.resolverManager().resolver(byId ? dao.idType() : (Class) options.get("fieldType"));
if (null == resolver) {
throw new IllegalArgumentException("Cannot find String value resolver for type: " + dao.idType());
}
requestParamName = S.string(value());
if (S.blank(requestParamName)) {
requestParamName = ParamValueLoaderService.bindName(spec);
}
if (!byId) {
if (S.blank(queryFieldName)) {
queryFieldName = requestParamName;
}
}
}
use of javax.validation.constraints.NotNull in project drill by apache.
the class DrillMetaImpl method drillFieldMetaData.
// Overriding fieldMetaData as Calcite version create ColumnMetaData with invalid offset
protected static ColumnMetaData.StructType drillFieldMetaData(Class<?> clazz) {
final List<ColumnMetaData> list = new ArrayList<>();
for (Field field : clazz.getFields()) {
if (Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers())) {
NotNull notNull = field.getAnnotation(NotNull.class);
boolean notNullable = (notNull != null || field.getType().isPrimitive());
list.add(drillColumnMetaData(AvaticaUtils.camelToUpper(field.getName()), list.size(), field.getType(), notNullable));
}
}
return ColumnMetaData.struct(list);
}
use of javax.validation.constraints.NotNull in project graylog2-server by Graylog2.
the class AdministrationResource method setAction.
@PUT
@Timed
@Path("/action")
@RequiresPermissions(SidecarRestPermissions.SIDECARS_UPDATE)
@ApiOperation(value = "Set collector actions in bulk")
@ApiResponses(value = { @ApiResponse(code = 400, message = "The supplied action is not valid.") })
@AuditEvent(type = SidecarAuditEventTypes.ACTION_UPDATE)
public Response setAction(@ApiParam(name = "JSON body", required = true) @Valid @NotNull BulkActionsRequest request) {
for (BulkActionRequest bulkActionRequest : request.collectors()) {
final List<CollectorAction> actions = bulkActionRequest.collectorIds().stream().map(collectorId -> CollectorAction.create(collectorId, request.action())).collect(Collectors.toList());
final CollectorActions collectorActions = actionService.fromRequest(bulkActionRequest.sidecarId(), actions);
actionService.saveAction(collectorActions);
}
return Response.accepted().build();
}
use of javax.validation.constraints.NotNull in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getTripOverviewDto.
@NotNull
private TripOverviewDto getTripOverviewDto(FishingActivityEntity activityEntity, String tripId) throws ServiceException {
Map<String, FishingActivityTypeDTO> typeDTOMap = populateFishingActivityReportListAndFishingTripSummary(tripId, null, null, true);
TripOverviewDto tripOverviewDto = new TripOverviewDto();
// Find out fishingTrip schemeId matching to tripId from fishingActivity object.
Set<FishingTripEntity> fishingTripEntities = activityEntity.getFishingTrips();
if (CollectionUtils.isNotEmpty(fishingTripEntities)) {
for (FishingTripEntity fishingTripEntity : fishingTripEntities) {
Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
if (tripId.equalsIgnoreCase(tripIdentifierEntity.getTripId())) {
TripIdDto tripIdDto = new TripIdDto();
tripIdDto.setId(tripId);
tripIdDto.setSchemeId(tripIdentifierEntity.getTripSchemeId());
List<TripIdDto> tripIdList = new ArrayList<>();
tripIdList.add(tripIdDto);
tripOverviewDto.setTripId(tripIdList);
break;
}
}
}
}
populateTripOverviewDto(typeDTOMap, tripOverviewDto);
return tripOverviewDto;
}
Aggregations