Search in sources :

Example 71 with NotNull

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)));
}
Also used : QueryEvent(com.airbnb.spinaltap.mysql.event.QueryEvent) BinlogFilePos(com.airbnb.spinaltap.mysql.BinlogFilePos) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Set(java.util.Set) NotNull(javax.validation.constraints.NotNull) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) Tables(com.google.common.collect.Tables) Slf4j(lombok.extern.slf4j.Slf4j) Lists(com.google.common.collect.Lists) Map(java.util.Map) Pattern(java.util.regex.Pattern) Table(com.google.common.collect.Table) Maps(com.google.common.collect.Maps) BinlogFilePos(com.airbnb.spinaltap.mysql.BinlogFilePos)

Example 72 with NotNull

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;
        }
    }
}
Also used : App(act.app.App) NotNull(javax.validation.constraints.NotNull)

Example 73 with NotNull

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);
}
Also used : Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) ColumnMetaData(org.apache.calcite.avatica.ColumnMetaData) NotNull(javax.validation.constraints.NotNull)

Example 74 with NotNull

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();
}
Also used : CollectorActions(org.graylog.plugins.sidecar.rest.models.CollectorActions) Produces(javax.ws.rs.Produces) SidecarService(org.graylog.plugins.sidecar.services.SidecarService) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) Configuration(org.graylog.plugins.sidecar.rest.models.Configuration) Valid(javax.validation.Valid) ApiOperation(io.swagger.annotations.ApiOperation) PaginatedList(org.graylog2.database.PaginatedList) AdministrationFilter(org.graylog.plugins.sidecar.filter.AdministrationFilter) MediaType(javax.ws.rs.core.MediaType) CollectorService(org.graylog.plugins.sidecar.services.CollectorService) SidecarConfiguration(org.graylog.plugins.sidecar.system.SidecarConfiguration) ClusterConfigService(org.graylog2.plugin.cluster.ClusterConfigService) Consumes(javax.ws.rs.Consumes) Locale(java.util.Locale) Map(java.util.Map) PluginRestResource(org.graylog2.plugin.rest.PluginRestResource) BadRequestException(javax.ws.rs.BadRequestException) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent) Predicate(java.util.function.Predicate) CollectorAction(org.graylog.plugins.sidecar.rest.models.CollectorAction) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) BulkActionRequest(org.graylog.plugins.sidecar.rest.requests.BulkActionRequest) Timed(com.codahale.metrics.annotation.Timed) List(java.util.List) SidecarSummary(org.graylog.plugins.sidecar.rest.models.SidecarSummary) Response(javax.ws.rs.core.Response) BulkActionsRequest(org.graylog.plugins.sidecar.rest.requests.BulkActionsRequest) Optional(java.util.Optional) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) ConfigurationService(org.graylog.plugins.sidecar.services.ConfigurationService) Sidecar(org.graylog.plugins.sidecar.rest.models.Sidecar) SearchQueryParser(org.graylog2.search.SearchQueryParser) ApiResponses(io.swagger.annotations.ApiResponses) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ImmutableList(com.google.common.collect.ImmutableList) AdministrationFiltersFactory(org.graylog.plugins.sidecar.filter.AdministrationFiltersFactory) AuditEvent(org.graylog2.audit.jersey.AuditEvent) Api(io.swagger.annotations.Api) SidecarRestPermissions(org.graylog.plugins.sidecar.permissions.SidecarRestPermissions) SearchQuery(org.graylog2.search.SearchQuery) AdministrationRequest(org.graylog.plugins.sidecar.rest.requests.AdministrationRequest) POST(javax.ws.rs.POST) ActiveSidecarFilter(org.graylog.plugins.sidecar.filter.ActiveSidecarFilter) SidecarAuditEventTypes(org.graylog.plugins.sidecar.audit.SidecarAuditEventTypes) RestResource(org.graylog2.shared.rest.resources.RestResource) SidecarListResponse(org.graylog.plugins.sidecar.rest.responses.SidecarListResponse) ActionService(org.graylog.plugins.sidecar.services.ActionService) ApiResponse(io.swagger.annotations.ApiResponse) Collector(org.graylog.plugins.sidecar.rest.models.Collector) PUT(javax.ws.rs.PUT) SidecarStatusMapper(org.graylog.plugins.sidecar.mapper.SidecarStatusMapper) BulkActionRequest(org.graylog.plugins.sidecar.rest.requests.BulkActionRequest) CollectorActions(org.graylog.plugins.sidecar.rest.models.CollectorActions) CollectorAction(org.graylog.plugins.sidecar.rest.models.CollectorAction) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent) AuditEvent(org.graylog2.audit.jersey.AuditEvent) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 75 with NotNull

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;
}
Also used : TripIdDto(eu.europa.ec.fisheries.ers.service.dto.view.TripIdDto) TripOverviewDto(eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto) NotNull(javax.validation.constraints.NotNull)

Aggregations

NotNull (javax.validation.constraints.NotNull)77 List (java.util.List)24 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)16 Inject (javax.inject.Inject)16 Logger (org.slf4j.Logger)14 ArrayList (java.util.ArrayList)13 LoggerFactory (org.slf4j.LoggerFactory)13 HashMap (java.util.HashMap)11 Response (javax.ws.rs.core.Response)10 Optional (java.util.Optional)9 Strings (com.google.common.base.Strings)8 Lists (com.google.common.collect.Lists)8 Set (java.util.Set)8 Valid (javax.validation.Valid)8 Api (io.swagger.annotations.Api)7 ApiParam (io.swagger.annotations.ApiParam)7 IOException (java.io.IOException)7 Collection (java.util.Collection)7 Nullable (javax.annotation.Nullable)7