@Override public Iterable<Entity> getAllOntologyEntities() { Stream<Entity> findAll = dataService.findAll(ONTOLOGY); return findAll.collect(Collectors.toList()); }
private void persistGeneNetworkScoreEntities(int rowNr, List<Entity> entities) { if ((rowNr % BATCH_SIZE) == 0) { System.out.println("inserting batch into database."); dataService .add(PACKAGE_SYSTEM + PACKAGE_SEPARATOR + GeneNetworkScoreMetaData.SIMPLE_NAME, entities.stream()); entities.clear(); } }
@Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional public void setActivationUser(String userId, Boolean active) { User mu = this.dataService.findOneById(USER, userId, User.class); mu.setActive(active); this.dataService.update(USER, mu); }
private Entity getPluginSettings(String entityTypeId) { return dataService.hasRepository(entityTypeId) ? dataService.findOneById(entityTypeId, getId()) : null; }
private void deletePackages(Set<Object> packageIds) { List<Package> packages = dataService .findAll(PackageMetadata.PACKAGE, packageIds.stream(), Package.class) .collect(toList()); if (!packages.isEmpty()) { List<Package> deletablePackages = getDeletablePackages(packages, packageIds); if (!deletablePackages.isEmpty()) { dataService.delete(PackageMetadata.PACKAGE, deletablePackages.stream()); } } }
private DataSet createDerivedDataSets(String userName, Integer targetDataSetId, List<Integer> sourceDataSetIds) { DataSet targetDataSet = dataService.findOne(DataSet.ENTITY_NAME, targetDataSetId, DataSet.class); DataSet derivedDataSet = new DataSet(); derivedDataSet.setIdentifier(createDerivedDataSetIdentifier(userName, targetDataSet.getId().toString(), sourceDataSetIds)); derivedDataSet.setName(createDerivedDataSetName(userName, targetDataSet.getName())); derivedDataSet.setProtocolUsed(targetDataSet.getProtocolUsed()); dataService.add(DataSet.ENTITY_NAME, derivedDataSet); dataService.getCrudRepository(DataSet.ENTITY_NAME).flush(); if (!dataService.hasRepository(derivedDataSet.getIdentifier())) { dataService.addRepository(new OmxRepository(dataService, searchService, derivedDataSet.getIdentifier(), new DefaultEntityValidator(dataService, new EntityAttributesValidator()))); } return derivedDataSet; }
private DataSet getDataSetForWorkFlowElement(Integer workflowElementId) { // get data set for the given workflow element Protocol protocol = dataService.findOne(Protocol.ENTITY_NAME, workflowElementId, Protocol.class); Iterable<DataSet> dataSets = dataService.findAll(DataSet.ENTITY_NAME, new QueryImpl().eq(DataSet.PROTOCOLUSED, protocol), DataSet.class); if (Iterables.size(dataSets) != 1) throw new RuntimeException("Workflow element must have exactly one data set"); return dataSets.iterator().next(); } }
private Entity upsert(AttributeMapping attributeMapping) { Entity result; if (attributeMapping.getIdentifier() == null) { attributeMapping.setIdentifier(idGenerator.generateId()); result = toAttributeMappingEntity(attributeMapping); dataService.add(attributeMappingMetaData.getId(), result); } else { result = toAttributeMappingEntity(attributeMapping); dataService.update(attributeMappingMetaData.getId(), result); } return result; }
/** * Updates the {@link IndexStatus} of a IndexAction and stores the change. * * @param indexAction the IndexAction of which the status is updated * @param status the new {@link IndexStatus} */ private void updateIndexActionStatus( IndexAction indexAction, IndexActionMetaData.IndexStatus status) { indexAction.setIndexStatus(status); dataService.update(INDEX_ACTION, indexAction); }
@Override public BeaconResponse info(String beaconId) { return dataService.findOneById(BEACON, beaconId, Beacon.class).toBeaconResponse(); } }
private IndexDependencyModel createIndexDependencyModel(Set<Impact> changes) { Set<String> entityTypeIds = changes.stream().map(Impact::getEntityTypeId).collect(toSet()); boolean hasReferences = dataService.query(ATTRIBUTE_META_DATA).in(REF_ENTITY_TYPE, entityTypeIds).count() > 0; if (hasReferences) { return new IndexDependencyModel(getEntityTypes()); } else { return new IndexDependencyModel(emptyList()); } }
private void delete(String entityTypeId, String untypedId) { EntityType entityType = dataService.getEntityType(entityTypeId); Object id = getTypedValue(untypedId, entityType.getIdAttribute()); if (ATTRIBUTE_META_DATA.equals(entityTypeId)) { dataService.getMeta().deleteAttributeById(id); } else { dataService.deleteById(entityTypeId, id); } }
/** * Checks if an entityTypeID already exists. Used to validate ID field in the "New dataset" tab * when creating a new integrated dataset. */ @GetMapping("/isNewEntity") @ResponseBody public boolean isNewEntity(@RequestParam String targetEntityTypeId) { return dataService.getEntityType(targetEntityTypeId) == null; }
@Override public StyleSheet findThemeByName(String themeName) { Query<StyleSheet> findByName = new QueryImpl<StyleSheet>().eq(StyleSheetMetadata.NAME, themeName); return dataService.findOne(StyleSheetMetadata.STYLE_SHEET, findByName, StyleSheet.class); }
/** * Creates a fully reconstructed MappingProject from an Entity retrieved from the repository. * * @param mappingTargetEntity Entity with {@link MappingProjectMetaData} metadata * @return fully reconstructed MappingProject */ private MappingTarget toMappingTarget(Entity mappingTargetEntity) { List<EntityMapping> entityMappings = Collections.emptyList(); String identifier = mappingTargetEntity.getString(MappingTargetMetaData.IDENTIFIER); if (!dataService.hasRepository(mappingTargetEntity.getString(MappingTargetMetaData.TARGET))) { return null; } EntityType target = dataService.getEntityType(mappingTargetEntity.getString(MappingTargetMetaData.TARGET)); if (mappingTargetEntity.getEntities(MappingTargetMetaData.ENTITY_MAPPINGS) != null) { List<Entity> entityMappingEntities = Lists.newArrayList( mappingTargetEntity.getEntities(MappingTargetMetaData.ENTITY_MAPPINGS)); entityMappings = entityMappingRepository.toEntityMappings(entityMappingEntities); } return new MappingTarget(identifier, target, entityMappings); } }
/** * Cleans up successful IndexJobExecutions that finished longer than five minutes ago. delay for a * minute to allow the transaction manager to become available */ @Scheduled(initialDelay = 1 * 60 * 1000, fixedRate = 5 * 60 * 1000) public void cleanupJobExecutions() { runAsSystem( () -> { LOG.trace("Clean up Index job executions..."); Instant fiveMinutesAgo = Instant.now().minus(5, ChronoUnit.MINUTES); boolean indexJobExecutionExists = dataService.hasRepository(IndexJobExecutionMeta.INDEX_JOB_EXECUTION); if (indexJobExecutionExists) { Stream<Entity> executions = dataService .getRepository(IndexJobExecutionMeta.INDEX_JOB_EXECUTION) .query() .lt(END_DATE, fiveMinutesAgo) .and() .eq(STATUS, SUCCESS.toString()) .findAll(); dataService.delete(IndexJobExecutionMeta.INDEX_JOB_EXECUTION, executions); LOG.debug("Cleaned up Index job executions."); } else { LOG.warn("{} does not exist", IndexJobExecutionMeta.INDEX_JOB_EXECUTION); } }); } }
private Repository<Entity> getTargetRepository(String entityTypeId, EntityType targetMetadata) { Repository<Entity> targetRepo; if (!dataService.hasRepository(entityTypeId)) { targetRepo = addTargetEntityType(targetMetadata); } else { targetRepo = dataService.getRepository(entityTypeId); compareTargetMetadatas(targetRepo.getEntityType(), targetMetadata); } return targetRepo; }
private void deleteRepository(String entityTypeId) { try { dataService.getMeta().deleteEntityType(entityTypeId); LOG.info("Deleted repository {}", entityTypeId); } catch (Exception ex) { LOG.error("Failed to delete existing writable repository {}", entityTypeId); } }
/** * Tests an algoritm by computing it for all entities in the source repository. * * @param mappingServiceRequest the {@link MappingServiceRequest} sent by the client * @return Map with the results and size of the source */ @RequestMapping(method = RequestMethod.POST, value = "/mappingattribute/testscript", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @ResponseBody public Map<String, Object> testScript(@RequestBody MappingServiceRequest mappingServiceRequest) { EntityType targetEntityType = dataService.getEntityType(mappingServiceRequest.getTargetEntityName()); Attribute targetAttribute = targetEntityType != null ? targetEntityType .getAttribute(mappingServiceRequest.getTargetAttributeName()) : null; Repository<Entity> sourceRepo = dataService.getRepository(mappingServiceRequest.getSourceEntityName()); Iterable<AlgorithmEvaluation> algorithmEvaluations = algorithmService .applyAlgorithm(targetAttribute, mappingServiceRequest.getAlgorithm(), sourceRepo); List<Object> calculatedValues = newArrayList( Iterables.transform(algorithmEvaluations, AlgorithmEvaluation::getValue)); return ImmutableMap.of("results", calculatedValues, "totalCount", Iterables.size(sourceRepo)); }
/** Checks if an entity exists. */ @GetMapping(value = "/{entityTypeId}/exist", produces = APPLICATION_JSON_VALUE) public boolean entityExists(@PathVariable("entityTypeId") String entityTypeId) { try { dataService.getRepository(entityTypeId); return true; } catch (UnknownEntityTypeException e) { return false; } }