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

Rework of IdMapping toward explicit Id-kinds #1970

Merged
merged 90 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
324cc58
initial rework of IdMapping including CQExternal, toward explicitly s…
awildturtok Jul 6, 2021
5c67f6f
Update AutoDoc
github-actions[bot] Jul 6, 2021
d3bac28
remove unnecessary helper classes
awildturtok Jul 7, 2021
cd2b6ea
Merge branch 'feature/external-headers-reworked' of https://github.co…
awildturtok Jul 7, 2021
560a4fa
Migrate format back to inline Types
awildturtok Jul 7, 2021
a666460
Merge remote-tracking branch 'origin/develop' into feature/external-h…
awildturtok Jul 7, 2021
c0d85cd
merge fixes
awildturtok Jul 7, 2021
cd4cdb6
Update AutoDoc
github-actions[bot] Jul 7, 2021
ac83e18
Add Id kind as part of IdMapping resolve step, to dissambiguate betwe…
awildturtok Jul 8, 2021
df98f55
don't use weird reflection magic
awildturtok Jul 8, 2021
5c51afa
Update AutoDoc
github-actions[bot] Jul 8, 2021
6b1685a
Don't use fancy CPS instead define mappings in config
awildturtok Jul 15, 2021
5c373dc
Merge branch 'feature/external-headers-reworked' of https://github.co…
awildturtok Jul 15, 2021
45fad70
fix serialization of EntityIdMap.java using JsonValue/JsonCreator
awildturtok Jul 16, 2021
9871230
some more nudging the Mapping into FrontendConfig
awildturtok Jul 20, 2021
986ec60
Also make OutputMapping rely on ColumnConfig
awildturtok Jul 20, 2021
32f832d
migrate all usage to queryUpload config
awildturtok Jul 23, 2021
f832fe9
also migrate Pseudomizer
awildturtok Jul 23, 2021
a8bdcda
move Pseduomization to IdPrinter and Conquery
awildturtok Jul 23, 2021
7a4ae6f
remove unused class
awildturtok Jul 23, 2021
f2963f3
Update AutoDoc
github-actions[bot] Jul 23, 2021
4d7c665
adds json defaults
awildturtok Jul 26, 2021
ac3cf5a
use noArgs+Setter instead
awildturtok Jul 26, 2021
c7e7bfc
adds missing Allargs for builder
awildturtok Jul 26, 2021
eb2c743
fix missing negation for resolving
awildturtok Jul 26, 2021
05e1a02
Update AutoDoc
github-actions[bot] Jul 26, 2021
b1fb70a
allow optional fields
awildturtok Jul 26, 2021
02a1888
add internalOnly anno
awildturtok Jul 26, 2021
ee76455
Merge remote-tracking branch 'origin/develop' into feature/external-h…
awildturtok Jul 26, 2021
cb2c039
also adds endpoint for uploading external result lists
awildturtok Jul 26, 2021
7424933
Update AutoDoc
github-actions[bot] Jul 26, 2021
d261a24
adds missing initialization of Table#getColumns
awildturtok Jul 27, 2021
34d058d
add exclude to DictionaryMapping
awildturtok Jul 27, 2021
1f06665
undo InternalOnly annos in conf as they will not be read
awildturtok Jul 27, 2021
ce394c4
only create Query, don't run it
awildturtok Jul 27, 2021
4f55967
check for validity of ColumnConfig and locale keys
awildturtok Jul 27, 2021
f620dd6
Update AutoDoc
github-actions[bot] Jul 27, 2021
70b5aea
use view to reduce API surface for QueryUpload
awildturtok Jul 27, 2021
5c6e72f
Update AutoDoc
github-actions[bot] Jul 27, 2021
0dbdcb2
remove more fields from API
awildturtok Jul 27, 2021
12e9e41
use the csv output directly from the endpoint
awildturtok Jul 27, 2021
6e362a8
Update AutoDoc
github-actions[bot] Jul 27, 2021
1b0fbaf
cleanup
awildturtok Jul 27, 2021
453ae3a
Update AutoDoc
github-actions[bot] Jul 27, 2021
8b0d745
add check for all-Case
awildturtok Jul 27, 2021
b5c07c4
Merge branch 'feature/external-headers-reworked' of https://github.co…
awildturtok Jul 27, 2021
5e8970d
adds documentation
awildturtok Jul 27, 2021
d80b2d1
Update AutoDoc
github-actions[bot] Jul 27, 2021
580e5d3
refactor PrimaryDictionary into it's own separate store
awildturtok Jul 28, 2021
7dae4c9
Update AutoDoc
github-actions[bot] Jul 28, 2021
b1a6444
don't use pretty print
awildturtok Jul 28, 2021
cfe8ead
cleanup Aggregator tests
awildturtok Jul 28, 2021
92afa4f
fix headers for aggregator tests
awildturtok Jul 28, 2021
ae361e0
Adds missing CentralRegistry for PrimaryDictionary
awildturtok Jul 28, 2021
e181cd5
fix headers of query tests
awildturtok Jul 28, 2021
d8e4a41
extracts api classes into api
awildturtok Aug 3, 2021
938cde8
Lazy get position of Column
awildturtok Aug 3, 2021
b444e1b
Fix START/END and provide test
awildturtok Aug 3, 2021
022ca06
delete unused StoreInfo
awildturtok Aug 3, 2021
1021ce8
adds much needed documentation to ColumnConfig
awildturtok Aug 3, 2021
d393bf3
Update AutoDoc
github-actions[bot] Aug 3, 2021
fe8c1a5
remove unused declarations and cleanup validation
awildturtok Aug 4, 2021
549ccc5
Allow reading of multiple ids
awildturtok Aug 4, 2021
667840d
more documentation
awildturtok Aug 4, 2021
62b33ac
adds even mor documentation and removes a double catch
awildturtok Aug 4, 2021
7e2b373
also check if we have no id in the column
awildturtok Aug 9, 2021
85cbd4b
add more decoration to ExternalUpload and resulting ManagedQuery
awildturtok Aug 10, 2021
40e3a4b
allow date format configuration via locale
thoniTUB Aug 10, 2021
4997a0f
allows to generalize locale mapping
thoniTUB Aug 10, 2021
f42783f
adds locale to dateformat mapping
thoniTUB Aug 11, 2021
37e9ddf
generalize parsing format of CDateSet and CDateRange
thoniTUB Aug 11, 2021
31a78c9
correct regex to work correctly with empty values
thoniTUB Aug 11, 2021
4e0bbb0
Update AutoDoc
github-actions[bot] Aug 11, 2021
24b2b04
adds missing break statements
thoniTUB Aug 11, 2021
dfa62b0
moa tests
thoniTUB Aug 11, 2021
a528f3e
WIP fix tests
thoniTUB Aug 11, 2021
634fabe
Update AutoDoc
github-actions[bot] Aug 11, 2021
1ad2f61
adds missing date range separator to fix all tests
thoniTUB Aug 12, 2021
deaa33c
Update AutoDoc
github-actions[bot] Aug 12, 2021
67ebd1d
cleanup Locale config
thoniTUB Aug 12, 2021
910d859
Update AutoDoc
github-actions[bot] Aug 12, 2021
f49972f
review changes
thoniTUB Aug 17, 2021
81c4399
localize excel date rendering
thoniTUB Aug 17, 2021
80cff19
make getPrintIdFields localized by localized label
awildturtok Aug 18, 2021
31cfa35
Merge remote-tracking branch 'origin/develop' into feature/external-h…
awildturtok Aug 19, 2021
d1cd232
post merge fixes
awildturtok Aug 19, 2021
7e1e1ac
Update AutoDoc
github-actions[bot] Aug 19, 2021
f167737
Merge remote-tracking branch 'origin/feature/external-headers-reworke…
thoniTUB Aug 19, 2021
b8aabc2
Update AutoDoc
github-actions[bot] Aug 19, 2021
2bf8441
Merge pull request #2013 from bakdata/feature/localized-date
thoniTUB Aug 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions autodoc/src/main/java/com/bakdata/conquery/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import com.bakdata.conquery.models.forms.configs.FormConfig;
import com.bakdata.conquery.models.forms.configs.FormConfig.FormConfigFullRepresentation;
import com.bakdata.conquery.models.forms.configs.FormConfig.FormConfigOverviewRepresentation;
import com.bakdata.conquery.models.identifiable.mapping.IdMappingConfig;
import com.bakdata.conquery.models.preproc.TableImportDescriptor;
import com.bakdata.conquery.models.preproc.TableInputDescriptor;
import com.bakdata.conquery.models.preproc.outputs.OutputDescription;
Expand Down Expand Up @@ -117,7 +116,6 @@ public class Constants {
.base(new Base(AuthorizationConfig.class, "An `AuthorizationConfig` defines the initial users that are created on application startup and other permission related options."))
.base(new Base(AuthenticationConfig.class, "An `AuthenticationConfig` is used to define how specific realms for authentication are configured."))
.base(new Base(PluginConfig.class, "A `PluginConfig` is used to define settings for Conquery plugins."))
.base(new Base(IdMappingConfig.class, "An `IdMappingConfig` is used to define how multi column entity IDs are printed and parsed"))
.otherClass(APIConfig.class)
.otherClass(ConqueryConfig.class)
.otherClass(ClusterConfig.class)
Expand Down
12 changes: 8 additions & 4 deletions backend/src/main/java/com/bakdata/conquery/Conquery.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import com.bakdata.conquery.commands.RecodeStoreCommand;
import com.bakdata.conquery.commands.ShardNode;
import com.bakdata.conquery.commands.StandaloneCommand;
import com.bakdata.conquery.io.jackson.InternalOnly;
import com.bakdata.conquery.io.jackson.Jackson;
import com.bakdata.conquery.io.jackson.MutableInjectableValues;
import com.bakdata.conquery.models.config.ConqueryConfig;
import com.bakdata.conquery.util.DateFormats;
import com.bakdata.conquery.util.UrlRewriteBundle;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.Application;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.configuration.EnvironmentVariableSubstitutor;
import io.dropwizard.configuration.JsonConfigurationFactory;
import io.dropwizard.configuration.SubstitutingSourceProvider;
import io.dropwizard.servlets.assets.AssetServlet;
Expand All @@ -46,7 +46,11 @@ public Conquery() {

@Override
public void initialize(Bootstrap<ConqueryConfig> bootstrap) {
Jackson.configure(bootstrap.getObjectMapper());
final ObjectMapper confMapper = bootstrap.getObjectMapper();
Jackson.configure(confMapper);

confMapper.setConfig(confMapper.getDeserializationConfig().withView(InternalOnly.class));

// check for java compiler, needed for the class generation
if (ToolProvider.getSystemJavaCompiler() == null) {
throw new IllegalStateException("Conquery requires to be run on either a JDK or a ServerJRE");
Expand All @@ -61,7 +65,7 @@ public void initialize(Bootstrap<ConqueryConfig> bootstrap) {
bootstrap.addCommand(new StandaloneCommand(this));
bootstrap.addCommand(new RecodeStoreCommand());

((MutableInjectableValues)bootstrap.getObjectMapper().getInjectableValues()).add(Validator.class, bootstrap.getValidatorFactory().getValidator());
((MutableInjectableValues) confMapper.getInjectableValues()).add(Validator.class, bootstrap.getValidatorFactory().getValidator());

// do some setup in other classes after initialization but before running a
// command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ public class ConqueryConstants {
public static final ResultInfo FEATURE_DATE_RANGE_INFO = new LocalizedDefaultResultInfo((l) -> C10N.get(ResultHeadersC10n.class, l).featureDateRange(), ResultType.DateRangeT.INSTANCE);
public static final ResultInfo OUTCOME_DATE_RANGE_INFO = new LocalizedDefaultResultInfo((l) -> C10N.get(ResultHeadersC10n.class, l).outcomeDateRange(), ResultType.DateRangeT.INSTANCE);

public static final String PRIMARY_DICTIONARY = "PRIMARY_DICTIONARY";

public static class AuthenticationUtil {
public static final String REALM_NAME = "CONQUERY";
}

public static DictionaryId getPrimaryDictionary(Dataset dataset) {
return DictionaryId.Parser.INSTANCE.parse(Arrays.asList(dataset.getName(), "primary_dictionary"));
return DictionaryId.Parser.INSTANCE.parse(Arrays.asList(dataset.getName(), PRIMARY_DICTIONARY));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
import java.util.stream.Stream;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;

import com.bakdata.conquery.apiv1.query.CQElement;
import com.bakdata.conquery.apiv1.query.ConceptQuery;
import com.bakdata.conquery.apiv1.query.ExternalUpload;
import com.bakdata.conquery.apiv1.query.Query;
import com.bakdata.conquery.apiv1.query.QueryDescription;
import com.bakdata.conquery.apiv1.query.SecondaryIdQuery;
import com.bakdata.conquery.apiv1.query.ExternalUploadResult;
import com.bakdata.conquery.apiv1.query.concept.specific.CQAnd;
import com.bakdata.conquery.apiv1.query.concept.specific.CQExternal;
import com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal;
import com.bakdata.conquery.io.result.ResultRender.ResultRendererProvider;
import com.bakdata.conquery.io.storage.MetaStorage;
import com.bakdata.conquery.metrics.ExecutionMetrics;
Expand Down Expand Up @@ -359,5 +363,37 @@ public FullExecutionStatus getQueryFullStatus(ManagedExecution<?> query, User us
return status;
}

/**
* Try to resolve the external upload, if successful, create query for the user and return id and statistics for that.
*/
public ExternalUploadResult uploadEntities(User user, Dataset dataset, ExternalUpload upload) {

final CQExternal.ResolveStatistic statistic =
CQExternal.resolveEntities(upload.getValues(), upload.getFormat(),
datasetRegistry.get(dataset.getId()).getStorage().getIdMapping(),
config.getFrontend().getQueryUpload(),
config.getPreprocessor().getParsers().getDateReader()
);

// Resolving nothing is a problem thus we fail.
if (statistic.getResolved().isEmpty()) {
throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST)
.entity(new ExternalUploadResult(null, 0, statistic.getUnresolvedId(), statistic.getUnreadableDate()))
.build());
}

final ConceptQuery query = new ConceptQuery(new CQExternal(upload.getFormat(), upload.getValues()));

// We only create the Query, really no need to execute it as it's only useful for composition.
final ManagedExecution<?> execution =
datasetRegistry.get(dataset.getId()).getExecutionManager()
.createExecution(datasetRegistry, query, user, dataset);

return new ExternalUploadResult(
execution.getId(),
statistic.getResolved().size(),
statistic.getUnresolvedId(),
statistic.getUnreadableDate()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.bakdata.conquery.apiv1.query;

import java.util.Arrays;
import java.util.List;

import com.bakdata.conquery.models.auth.entities.User;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.dropwizard.validation.ValidationMethod;
import lombok.Getter;
import lombok.RequiredArgsConstructor;


/**
* Data Container for API call of {@link com.bakdata.conquery.resources.api.QueryResource#upload(User, ExternalUpload)}.
*
* This class acts as a wrapper for {@link com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal}.
*/
@RequiredArgsConstructor
@Getter
public class ExternalUpload {

private final List<String> format;
private final String[][] values;

@JsonIgnore
@ValidationMethod(message = "Values and Format are not of same width.")
public boolean isAllSameLength() {
final int expected = format.size();
return Arrays.stream(values).mapToInt(a -> a.length).allMatch(v -> expected == v);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.bakdata.conquery.apiv1.query;

import java.util.List;

import com.bakdata.conquery.models.auth.entities.User;
import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import lombok.Data;

/**
* Result Container for responses of {@link com.bakdata.conquery.resources.api.QueryResource#upload(User, ExternalUpload)}.
*/
@Data
public class ExternalUploadResult {
/**
* Id of created execution of uploaded data.
*/
private final ManagedExecutionId execution;

/**
* Number of successfully resolved rows.
*/
private final int resolved;

/**
* Content of rows where no Id could be resolved.
*/
private final List<String[]> unresolvedId;
/**
* Content of rows where dates could not be read.
*/
private final List<String[]> unreadableDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.bakdata.conquery.apiv1.query.concept.specific.CQExternal;
import com.bakdata.conquery.io.cps.CPSBase;
import com.bakdata.conquery.io.jackson.InternalOnly;
import com.bakdata.conquery.models.auth.entities.User;
Expand All @@ -17,6 +16,7 @@
import com.bakdata.conquery.models.identifiable.ids.NamespacedIdentifiable;
import com.bakdata.conquery.models.query.QueryResolveContext;
import com.bakdata.conquery.models.query.Visitable;
import com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal;
import com.bakdata.conquery.models.query.visitor.QueryVisitor;
import com.bakdata.conquery.models.worker.DatasetRegistry;
import com.bakdata.conquery.util.QueryUtils;
Expand Down
Loading