use of com.epam.pipeline.entity.BaseEntity in project cloud-pipeline by epam.
the class ParameterMapper method resolveConfigurations.
public List<ResolvedConfiguration> resolveConfigurations(AnalysisConfiguration<? extends AbstractRunConfigurationEntry> configuration) {
FolderWithMetadata project = folderManager.getProject(configuration.getConfigurationId(), AclClass.CONFIGURATION);
Map<String, PipeConfValue> projectData = project == null ? new HashMap<>() : project.getData();
List<? extends AbstractRunConfigurationEntry> entries = configuration.getEntries();
if (CollectionUtils.isEmpty(configuration.getEntitiesIds())) {
return Collections.singletonList(resolveParameters(entries, projectData));
}
// In case of array references one entity may be expanded to
// list of references entities, e.g. SampleSet is expanded
// to list of Sample entities
// TODO: The only reason to store it as map - is to add association to run
// TODO: to initial entity, from which link comes. Find better solution.
Map<Long, List<MetadataEntity>> targetEntities = fetchAndExpandInputEntities(configuration);
// resolve all parameter references in configurations
Map<Long, ResolvedConfiguration> resolvedConfigurations = targetEntities.values().stream().flatMap(Collection::stream).collect(Collectors.toMap(BaseEntity::getId, entity -> resolveParameters(entity, entries, projectData)));
return targetEntities.entrySet().stream().map(idToEntities -> idToEntities.getValue().stream().map(entity -> {
ResolvedConfiguration currentConfiguration = resolvedConfigurations.get(entity.getId());
currentConfiguration.getAssociatedEntityIds().add(idToEntities.getKey());
return currentConfiguration;
}).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());
}
use of com.epam.pipeline.entity.BaseEntity in project cloud-pipeline by epam.
the class FirecloudRunner method runAnalysis.
@Override
public List<PipelineRun> runAnalysis(AnalysisConfiguration<FirecloudRunConfigurationEntry> configuration) {
Assert.state(CollectionUtils.isNotEmpty(configuration.getEntitiesIds()), "Entities are required to run analysis in Firecloud");
FolderWithMetadata project = folderManager.getProject(configuration.getConfigurationId(), AclClass.CONFIGURATION);
Assert.notNull(project, "Project folder must be specified to run analysis in Firecloud.");
List<Long> entities = parameterMapper.fetchAndExpandInputEntities(configuration).values().stream().flatMap(Collection::stream).map(BaseEntity::getId).collect(Collectors.toList());
// TODO: after merge - add check that FC class is filled
configuration.getEntries().forEach(this::validateFirecloudConfiguration);
FirecloudConfiguration settings = buildFirecloudConfig(configuration.getRefreshToken());
return configuration.getEntries().stream().map(entry -> runFirecloudAnalysis(settings, entry, configuration.getConfigurationId(), entities, project.getId())).collect(Collectors.toList());
}
use of com.epam.pipeline.entity.BaseEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method loadAllEntitiesPermissions.
public EntityWithPermissionVO loadAllEntitiesPermissions(AclClass aclClass, Integer page, Integer pageSize, boolean expandGroups, Integer filterMask) {
EntityWithPermissionVO result = new EntityWithPermissionVO();
Collection<? extends AbstractSecuredEntity> entities = entityManager.loadAllWithParents(aclClass, page, pageSize);
Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions = getEntitiesPermissions(entities);
result.setTotalCount(entityManager.loadTotalCount(aclClass));
List<EntityPermission> permissions = entities.stream().distinct().sorted(Comparator.comparingLong(BaseEntity::getId)).map(entity -> getEntityPermission(allPermissions, entity)).collect(toList());
if (expandGroups) {
expandGroups(permissions);
if (filterMask != null) {
permissions.forEach(entry -> {
Set<AclPermissionEntry> filtered = SetUtils.emptyIfNull(entry.getPermissions()).stream().filter(permission -> permissionsService.isMaskBitSet(permission.getMask(), filterMask)).collect(toSet());
entry.setPermissions(filtered);
});
}
}
result.setEntityPermissions(permissions);
return result;
}
use of com.epam.pipeline.entity.BaseEntity in project cloud-pipeline by epam.
the class ConfigurationEntryMapper method getContentBuilder.
private XContentBuilder getContentBuilder(final EntityContainer<ConfigurationEntryDoc> container) {
RunConfiguration configuration = container.getEntity().getConfiguration();
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
jsonBuilder.startObject();
AbstractRunConfigurationEntry entry = container.getEntity().getEntry();
jsonBuilder.field(DOC_TYPE_FIELD, SearchDocumentType.CONFIGURATION.name()).field("id", container.getEntity().getId()).field("name", Optional.ofNullable(entry).map(AbstractRunConfigurationEntry::getName).orElse(configuration.getName())).field("description", configuration.getName() + " " + StringUtils.defaultIfBlank(configuration.getDescription(), StringUtils.EMPTY)).field("createdDate", parseDataToString(configuration.getCreatedDate())).field("parentId", Optional.ofNullable(configuration.getParent()).map(BaseEntity::getId).orElse(null));
buildUserContent(container.getOwner(), jsonBuilder);
buildMetadata(container.getMetadata(), jsonBuilder);
buildPermissions(container.getPermissions(), jsonBuilder);
if (entry != null) {
buildConfigurationEntry(entry, container.getEntity().getPipeline(), jsonBuilder);
}
jsonBuilder.endObject();
return jsonBuilder;
} catch (IOException e) {
throw new IllegalArgumentException("Failed to create elasticsearch document for run configuration: ", e);
}
}
Aggregations