-
Notifications
You must be signed in to change notification settings - Fork 12
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
Infocard for Entity Preview #2616
Changes from all commits
0320294
0626d96
9aaf318
f94bcdb
4b14122
86d05b3
e30f3e4
a7fe3f3
b264cc8
47c348f
0ac87ea
84c6eb3
e53ec44
aebff7c
ae79d2e
4e9ae37
57128ca
5cbb457
166e9fd
acc0ab4
6175260
254e201
66c1dff
c597b95
94158d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.bakdata.conquery.models.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.ws.rs.core.UriBuilder; | ||
|
||
import com.bakdata.conquery.models.auth.entities.Subject; | ||
import com.bakdata.conquery.models.common.Range; | ||
import com.bakdata.conquery.models.datasets.Dataset; | ||
import com.bakdata.conquery.models.datasets.concepts.Connector; | ||
import com.bakdata.conquery.models.datasets.concepts.select.Select; | ||
import com.bakdata.conquery.models.error.ConqueryError; | ||
import com.bakdata.conquery.models.identifiable.ids.specific.SelectId; | ||
import com.bakdata.conquery.models.query.PrintSettings; | ||
import com.bakdata.conquery.models.query.resultinfo.SelectResultInfo; | ||
import com.bakdata.conquery.models.worker.DatasetRegistry; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Data | ||
@Slf4j | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PreviewConfig { | ||
/** | ||
* Selects to be used in {@link com.bakdata.conquery.apiv1.QueryProcessor#getSingleEntityExport(Subject, UriBuilder, String, String, List, Dataset, Range)}. | ||
* To be displayed as additional infos. | ||
* | ||
* @implSpec the order of selects is the order of the output fields. | ||
*/ | ||
private List<InfoCardSelect> infoCardSelects = List.of(); | ||
|
||
@Data | ||
public static class InfoCardSelect { | ||
/** | ||
* User facing label of the select. | ||
*/ | ||
private final String label; | ||
/** | ||
* Id (without dataset) of the select. | ||
* | ||
* @implNote this id will be resolved at runtime and cannot be validated at startup. | ||
*/ | ||
private final String id; | ||
} | ||
|
||
/** | ||
* Used to map {@link SelectResultInfo} to {@link InfoCardSelect#getLabel()} via {@link PrintSettings#getColumnNamer()}. | ||
*/ | ||
public String resolveSelectLabel(SelectResultInfo info) { | ||
Comment on lines
+52
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wo spielt der There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Schau mal in |
||
final String id = info.getSelect().getId().toStringWithoutDataset(); | ||
|
||
for (InfoCardSelect infoCardSelect : getInfoCardSelects()) { | ||
if (infoCardSelect.getId().equals(id)) { | ||
return infoCardSelect.getLabel(); | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException(String.format("%s is not an InfoCard Select", info)); | ||
} | ||
|
||
/** | ||
* Find infoCard-selects by id within Dataset. | ||
*/ | ||
public List<Select> resolveInfoCardSelects(Dataset dataset, DatasetRegistry registry) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. laut gh wird die methode in dieser Datei Zeile 395 benutzt 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Werden die Funktionen noch benutzt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
final List<Select> infoCardSelects = new ArrayList<>(); | ||
|
||
for (InfoCardSelect select : getInfoCardSelects()) { | ||
final SelectId selectId = SelectId.Parser.INSTANCE.parsePrefixed(dataset.getName(), select.getId()); | ||
final Select resolved = registry.resolve(selectId); | ||
|
||
infoCardSelects.add(resolved); | ||
} | ||
|
||
final Set<Select> nonConnectorSelects = infoCardSelects.stream() | ||
.filter(select -> !(select.getHolder() instanceof Connector)) | ||
.collect(Collectors.toSet()); | ||
|
||
if (!nonConnectorSelects.isEmpty()) { | ||
log.error("The selects {} are not connector-Selects", nonConnectorSelects); | ||
throw new ConqueryError.ExecutionCreationErrorUnspecified(); | ||
} | ||
|
||
return infoCardSelects; | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Würde ich ein eine Util Klasse packen und doku bitte