code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
private void injectExistingEntityTypeAttributeIdentifiers(
List<? extends EntityType> entityTypes) {
Map<String, EntityType> existingEntityTypeMap =
dataService
.findAll(ENTITY_TYPE_META_DATA, EntityType.class)
.collect(toMap(EntityType::getId, entityType -> entityType));
... | java |
private void addAttributeInternal(EntityType entityType, Attribute attr) {
if (!isPersisted(attr)) {
return;
}
if (isMultipleReferenceType(attr)) {
createJunctionTable(entityType, attr);
if (attr.getDefaultValue() != null && !attr.isNillable()) {
@SuppressWarnings("unchecked")
... | java |
private static boolean isPersisted(Attribute attr) {
return !attr.hasExpression()
&& attr.getDataType() != COMPOUND
&& !(attr.getDataType() == ONE_TO_MANY && attr.isMappedBy());
} | java |
private void updateColumn(EntityType entityType, Attribute attr, Attribute updatedAttr) {
// nullable changes
if (!Objects.equals(attr.isNillable(), updatedAttr.isNillable())) {
updateNillable(entityType, attr, updatedAttr);
}
// unique changes
if (!Objects.equals(attr.isUnique(), updatedAttr... | java |
private void updateRefEntity(EntityType entityType, Attribute attr, Attribute updatedAttr) {
if (isSingleReferenceType(attr) && isSingleReferenceType(updatedAttr)) {
dropForeignKey(entityType, attr);
if (attr.getRefEntity().getIdAttribute().getDataType()
!= updatedAttr.getRefEntity().getIdAtt... | java |
private void updateEnumOptions(EntityType entityType, Attribute attr, Attribute updatedAttr) {
if (attr.getDataType() == ENUM) {
if (updatedAttr.getDataType() == ENUM) {
// update check constraint
dropCheckConstraint(entityType, attr);
createCheckConstraint(entityType, updatedAttr);
... | java |
private void updateDataType(EntityType entityType, Attribute attr, Attribute updatedAttr) {
Attribute idAttr = entityType.getIdAttribute();
if (idAttr != null && idAttr.getName().equals(attr.getName())) {
throw new MolgenisDataException(
format(
"Data type of entity [%s] attribute ... | java |
private void updateUnique(EntityType entityType, Attribute attr, Attribute updatedAttr) {
if (attr.isUnique() && !updatedAttr.isUnique()) {
Attribute idAttr = entityType.getIdAttribute();
if (idAttr != null && idAttr.getName().equals(attr.getName())) {
throw new MolgenisDataException(
... | java |
private void updateReadonly(EntityType entityType, Attribute attr, Attribute updatedAttr) {
Map<String, Attribute> readonlyTableAttrs =
getTableAttributesReadonly(entityType)
.collect(toLinkedMap(Attribute::getName, Function.identity()));
if (!readonlyTableAttrs.isEmpty()) {
dropTableT... | java |
private void registerRefEntityIndexActions() {
// bidirectional attribute: register indexing actions for other side
getEntityType()
.getMappedByAttributes()
.forEach(
mappedByAttr -> {
EntityType refEntity = mappedByAttr.getRefEntity();
indexActionRegister... | java |
private void registerRefEntityIndexActions(Entity entity) {
// bidirectional attribute: register indexing actions for other side
getEntityType()
.getMappedByAttributes()
.forEach(
mappedByAttr -> {
EntityType mappedByAttrRefEntity = mappedByAttr.getRefEntity();
... | java |
private Multimap<Object, Object> selectMrefIDsForAttribute(
EntityType entityType,
AttributeType idAttributeDataType,
Attribute mrefAttr,
Set<Object> ids,
AttributeType refIdDataType) {
Stopwatch stopwatch = null;
if (LOG.isTraceEnabled()) stopwatch = createStarted();
String j... | java |
void appendLog(String formattedMessage) {
if (logTruncated) return;
String combined = join(getLog(), formattedMessage);
if (combined.length() > MAX_LOG_LENGTH) {
String truncated = abbreviate(combined, MAX_LOG_LENGTH - TRUNCATION_BANNER.length() * 2 - 2);
combined = join(new String[] {TRUNCATION... | java |
public ScriptResult runScript(String scriptName, Map<String, Object> parameters) {
Script script =
dataService.query(SCRIPT, Script.class).eq(ScriptMetadata.NAME, scriptName).findOne();
if (script == null) {
throw new UnknownEntityException(SCRIPT, scriptName);
}
if (script.getParameters(... | java |
private void convertIdtoLabelLabels(
List<Object> idLabels, EntityType entityType, DataService dataService) {
final int nrLabels = idLabels.size();
if (nrLabels > 0) {
// Get entities for ids
// Use Iterables.transform to work around List<String> to Iterable<Object> cast error
Stream<Obj... | java |
public static @Nullable @CheckForNull String getCurrentUsername() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return null;
}
return getUsername(authentication);
} | java |
public static boolean currentUserHasRole(String... roles) {
if (roles == null || roles.length == 0) return false;
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
Collection<? extends GrantedAuthority> authorities = authentication.g... | java |
public static boolean currentUserIsAuthenticated() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
return authentication != null && authentication.isAuthenticated() && !currentUserIsAnonymous();
} | java |
@Override
public Entity findOneById(Object id) {
if (cacheable
&& !transactionInformation.isEntireRepositoryDirty(getEntityType())
&& !transactionInformation.isEntityDirty(EntityKey.create(getEntityType(), id))) {
return l2Cache.get(delegate(), id);
}
return delegate().findOneById(id... | java |
private List<Entity> findAllBatch(List<Object> ids) {
String entityTypeId = getEntityType().getId();
Multimap<Boolean, Object> partitionedIds =
Multimaps.index(
ids, id -> transactionInformation.isEntityDirty(EntityKey.create(entityTypeId, id)));
Collection<Object> cleanIds = partitioned... | java |
public void evictAll(EntityType entityType) {
cache
.asMap()
.keySet()
.stream()
.filter(e -> e.getEntityTypeId().equals(entityType.getId()))
.forEach(cache::invalidate);
} | java |
public Optional<CacheHit<Entity>> getIfPresent(EntityType entityType, Object id) {
EntityKey key = EntityKey.create(entityType, id);
return Optional.ofNullable(cache.getIfPresent(key))
.map(cacheHit -> hydrate(cacheHit, entityType));
} | java |
public void put(Entity entity) {
EntityType entityType = entity.getEntityType();
cache.put(
EntityKey.create(entityType, entity.getIdValue()),
CacheHit.of(entityHydration.dehydrate(entity)));
} | java |
public static File saveToTempFile(Part part) throws IOException {
String filename = getOriginalFileName(part);
if (filename == null) {
return null;
}
File file = File.createTempFile("molgenis-", "." + StringUtils.getFilenameExtension(filename));
FileCopyUtils.copy(part.getInputStream(), new F... | java |
public static File saveToTempFolder(Part part) throws IOException {
String filename = getOriginalFileName(part);
if (filename == null) {
return null;
}
File file = new File(FileUtils.getTempDirectory(), filename);
FileCopyUtils.copy(part.getInputStream(), new FileOutputStream(file));
ret... | java |
public static String getOriginalFileName(Part part) {
String contentDisposition = part.getHeader("content-disposition");
if (contentDisposition != null) {
for (String cd : contentDisposition.split(";")) {
if (cd.trim().startsWith("filename")) {
String path = cd.substring(cd.indexOf('=')... | java |
@Bean
public JobFactory<ScriptJobExecution> scriptJobFactory() {
return new JobFactory<ScriptJobExecution>() {
@Override
public Job<ScriptResult> createJob(ScriptJobExecution scriptJobExecution) {
final String name = scriptJobExecution.getName();
final String parameterString = scriptJo... | java |
@PreAuthorize("hasAnyRole('ROLE_SU')")
@PostMapping("/upload-logo")
public String uploadLogo(@RequestParam("logo") Part part, Model model) throws IOException {
String contentType = part.getContentType();
if ((contentType == null) || !contentType.startsWith("image")) {
model.addAttribute("errorMessage"... | java |
public Stream<EntityType> getCompatibleEntityTypes(EntityType target) {
return dataService
.getMeta()
.getEntityTypes()
.filter(candidate -> !candidate.isAbstract())
.filter(isCompatible(target));
} | java |
private Set<Impact> collectResult(
List<Impact> singleEntityChanges,
List<Impact> wholeRepoActions,
Set<String> dependentEntityIds) {
Set<String> wholeRepoIds =
union(
wholeRepoActions.stream().map(Impact::getEntityTypeId).collect(toImmutableSet()),
dependentEntityI... | java |
public Object eval(Bindings bindings, String expression) throws ScriptException {
CompiledScript compiledExpression = requireNonNull(expressions.get(expression));
Object returnValue = compiledExpression.eval(bindings);
return convertNashornValue(returnValue);
} | java |
public void addFileRepositoryCollectionClass(
Class<? extends FileRepositoryCollection> clazz, Set<String> fileExtensions) {
for (String extension : fileExtensions) {
fileRepositoryCollections.put(extension.toLowerCase(), clazz);
}
} | java |
public FileRepositoryCollection createFileRepositoryCollection(File file) {
Class<? extends FileRepositoryCollection> clazz;
String extension =
FileExtensionUtils.findExtensionFromPossibilities(
file.getName(), fileRepositoryCollections.keySet());
clazz = fileRepositoryCollections.get(... | java |
private static boolean hasNewMappedByAttrs(EntityType entityType, EntityType existingEntityType) {
Set<String> mappedByAttrs =
entityType.getOwnMappedByAttributes().map(Attribute::getName).collect(toSet());
Set<String> existingMappedByAttrs =
existingEntityType.getOwnMappedByAttributes().map(At... | java |
private void upsertAttributes(EntityType entityType, EntityType existingEntityType) {
// analyze both compound and atomic attributes owned by the entity
Map<String, Attribute> attrsMap =
stream(entityType.getOwnAllAttributes())
.collect(toMap(Attribute::getName, Function.identity()));
Ma... | java |
public EntityImportReport doImport(EmxImportJob job) {
try {
return writer.doImport(job);
} catch (Exception e) {
LOG.error("Error handling EmxImportJob", e);
throw e;
}
} | java |
private Optional<String> tryGetEntityTypeName(String tableName) {
EntityTypeDescription entityTypeDescription =
entityTypeRegistry.getEntityTypeDescription(tableName);
String entityTypeId = entityTypeDescription != null ? entityTypeDescription.getId() : null;
return Optional.ofNullable(entityTypeId)... | java |
private Optional<String> tryGetAttributeName(String tableName, String colName) {
String attributeName;
EntityTypeDescription entityTypeDescription =
entityTypeRegistry.getEntityTypeDescription(tableName);
if (entityTypeDescription != null) {
AttributeDescription attrDescription =
en... | java |
private void assignUniqueLabel(Package pack, Package targetPackage) {
Set<String> existingLabels;
if (targetPackage != null) {
existingLabels = stream(targetPackage.getChildren()).map(Package::getLabel).collect(toSet());
} else {
existingLabels =
dataService
.query(PACKAG... | java |
public Map<String, Object> dehydrate(Entity entity) {
LOG.trace("Dehydrating entity {}", entity);
Map<String, Object> dehydratedEntity = newHashMap();
EntityType entityType = entity.getEntityType();
entityType
.getAtomicAttributes()
.forEach(
attribute -> {
// ... | java |
public void move(String sourceDir, String targetDir) throws IOException {
validatePathname(sourceDir);
validatePathname(targetDir);
Files.move(
Paths.get(getStorageDir() + File.separator + sourceDir),
Paths.get(getStorageDir() + File.separator + targetDir));
} | java |
private boolean hasAttributeThatReferences(EntityType candidate, String entityTypeId) {
Iterable<Attribute> attributes = candidate.getOwnAtomicAttributes();
return stream(attributes)
.filter(Attribute::hasRefEntity)
.map(attribute -> attribute.getRefEntity().getId())
.anyMatch(entityType... | java |
public QueryRule createDisMaxQueryRuleForAttribute(
Set<String> searchTerms, Collection<OntologyTerm> ontologyTerms) {
List<String> queryTerms = new ArrayList<>();
if (searchTerms != null) {
queryTerms.addAll(
searchTerms
.stream()
.filter(StringUtils::isNotBla... | java |
public QueryRule createDisMaxQueryRuleForTerms(List<String> queryTerms) {
List<QueryRule> rules = new ArrayList<>();
queryTerms
.stream()
.filter(StringUtils::isNotEmpty)
.map(this::escapeCharsExcludingCaretChar)
.forEach(
query -> {
rules.add(new QueryR... | java |
public QueryRule createBoostedDisMaxQueryRuleForTerms(
List<String> queryTerms, Double boostValue) {
QueryRule finalDisMaxQuery = createDisMaxQueryRuleForTerms(queryTerms);
if (boostValue != null && boostValue.intValue() != 0) {
finalDisMaxQuery.setValue(boostValue);
}
return finalDisMaxQuer... | java |
public QueryRule createShouldQueryRule(String multiOntologyTermIri) {
QueryRule shouldQueryRule = new QueryRule(new ArrayList<>());
shouldQueryRule.setOperator(Operator.SHOULD);
for (String ontologyTermIri : multiOntologyTermIri.split(COMMA_CHAR)) {
OntologyTerm ontologyTerm = ontologyService.getOntol... | java |
public List<String> parseOntologyTermQueries(OntologyTerm ontologyTerm) {
List<String> queryTerms =
getOtLabelAndSynonyms(ontologyTerm)
.stream()
.map(this::processQueryString)
.collect(Collectors.toList());
for (OntologyTerm childOt : ontologyService.getChildren(ont... | java |
public Set<String> getOtLabelAndSynonyms(OntologyTerm ontologyTerm) {
Set<String> allTerms = Sets.newLinkedHashSet(ontologyTerm.getSynonyms());
allTerms.add(ontologyTerm.getLabel());
return allTerms;
} | java |
public List<String> getAttributeIdentifiers(EntityType sourceEntityType) {
Entity entityTypeEntity =
dataService.findOne(
ENTITY_TYPE_META_DATA,
new QueryImpl<>().eq(EntityTypeMetadata.ID, sourceEntityType.getId()));
if (entityTypeEntity == null)
throw new MolgenisDataAcce... | java |
private Entity toEntity(EntityType entityType, Entity emxEntity) {
Entity entity = entityManager.create(entityType, POPULATE);
for (Attribute attr : entityType.getAtomicAttributes()) {
if (attr.getExpression() == null && !attr.isMappedBy()) {
String attrName = attr.getName();
Object emxVal... | java |
private Column createColumnFromCell(Sheet sheet, Cell cell) {
if (cell.getCellTypeEnum() == CellType.STRING) {
return Column.create(
cell.getStringCellValue(),
cell.getColumnIndex(),
getColumnDataFromSheet(sheet, cell.getColumnIndex()));
} else {
throw new MolgenisDataE... | java |
private Object getCellValue(Cell cell) {
Object value;
// Empty cells are null, instead of BLANK
if (cell == null) {
return null;
}
switch (cell.getCellTypeEnum()) {
case STRING:
value = cell.getStringCellValue();
break;
case NUMERIC:
if (isCellDateFormatt... | java |
public void validate(EntityType entityType) {
validateEntityId(entityType);
validateEntityLabel(entityType);
validatePackage(entityType);
validateExtends(entityType);
validateOwnAttributes(entityType);
Map<String, Attribute> ownAllAttrMap =
stream(entityType.getOwnAllAttributes())
... | java |
void validateBackend(EntityType entityType) {
// Validate backend exists
String backendName = entityType.getBackend();
if (!dataService.getMeta().hasBackend(backendName)) {
throw new MolgenisValidationException(
new ConstraintViolation(format("Unknown backend [%s]", backendName)));
}
} | java |
static void validateOwnLookupAttributes(
EntityType entityType, Map<String, Attribute> ownAllAttrMap) {
// Validate lookup attributes
entityType
.getOwnLookupAttributes()
.forEach(
ownLookupAttr -> {
// Validate that lookup attribute is in the attributes list
... | java |
static void validateOwnLabelAttribute(
EntityType entityType, Map<String, Attribute> ownAllAttrMap) {
// Validate label attribute
Attribute ownLabelAttr = entityType.getOwnLabelAttribute();
if (ownLabelAttr != null) {
// Validate that label attribute is in the attributes list
Attribute own... | java |
static void validateOwnIdAttribute(EntityType entityType, Map<String, Attribute> ownAllAttrMap) {
// Validate ID attribute
Attribute ownIdAttr = entityType.getOwnIdAttribute();
if (ownIdAttr != null) {
// Validate that ID attribute is in the attributes list
Attribute ownAttr = ownAllAttrMap.get(... | java |
static void validateExtends(EntityType entityType) {
EntityType entityTypeExtends = entityType.getExtends();
if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) {
throw new MolgenisValidationException(
new ConstraintViolation(
format(
"EntityType [%s... | java |
void validatePackage(EntityType entityType) {
Package pack = entityType.getPackage();
if (pack != null
&& isSystemPackage(pack)
&& !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) {
throw new MolgenisValidationException(
new ConstraintViolation(
fo... | java |
void register(String repoFullName) {
lock.writeLock().lock();
try {
if (!entityListenersByRepo.containsKey(requireNonNull(repoFullName))) {
entityListenersByRepo.put(repoFullName, HashMultimap.create());
}
} finally {
lock.writeLock().unlock();
}
} | java |
Stream<Entity> updateEntities(String repoFullName, Stream<Entity> entities) {
lock.readLock().lock();
try {
verifyRepoRegistered(repoFullName);
SetMultimap<Object, EntityListener> entityListeners =
this.entityListenersByRepo.get(repoFullName);
return entities.filter(
entity... | java |
void updateEntity(String repoFullName, Entity entity) {
lock.readLock().lock();
try {
verifyRepoRegistered(repoFullName);
SetMultimap<Object, EntityListener> entityListeners =
this.entityListenersByRepo.get(repoFullName);
Set<EntityListener> entityEntityListeners = entityListeners.ge... | java |
public void addEntityListener(String repoFullName, EntityListener entityListener) {
lock.writeLock().lock();
try {
verifyRepoRegistered(repoFullName);
SetMultimap<Object, EntityListener> entityListeners =
this.entityListenersByRepo.get(repoFullName);
entityListeners.put(entityListene... | java |
public boolean removeEntityListener(String repoFullName, EntityListener entityListener) {
lock.writeLock().lock();
try {
verifyRepoRegistered(repoFullName);
SetMultimap<Object, EntityListener> entityListeners =
this.entityListenersByRepo.get(repoFullName);
if (entityListeners.contain... | java |
boolean isEmpty(String repoFullName) {
lock.readLock().lock();
try {
verifyRepoRegistered(repoFullName);
return entityListenersByRepo.get(repoFullName).isEmpty();
} finally {
lock.readLock().unlock();
}
} | java |
private void verifyRepoRegistered(String repoFullName) {
lock.readLock().lock();
try {
if (!entityListenersByRepo.containsKey(requireNonNull(repoFullName))) {
LOG.error(
"Repository [{}] is not registered in the entity listeners service", repoFullName);
throw new MolgenisDataEx... | java |
@Transactional
public void populateLocalizationStrings(AllPropertiesMessageSource source) {
source
.getAllMessageIds()
.asMap()
.forEach(
(namespace, messageIds) ->
updateNamespace(source, namespace, ImmutableSet.copyOf(messageIds)));
} | java |
@SuppressWarnings("squid:S3752") // multiple methods required
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
public String forwardDefaultMenuDefaultPlugin(Model model) {
Menu menu =
menuReaderService
.getMenu()
.orElseThrow(() -> new RuntimeException("main menu... | java |
private EntityPermission getPermission(Action operation) {
EntityPermission result;
switch (operation) {
case COUNT:
case READ:
result = EntityPermission.READ;
break;
case UPDATE:
result = EntityPermission.UPDATE;
break;
case DELETE:
result = Entit... | java |
@Bean
public JobFactory<MappingJobExecution> mappingJobFactory() {
return new JobFactory<MappingJobExecution>() {
@Override
public Job createJob(MappingJobExecution mappingJobExecution) {
final String mappingProjectId = mappingJobExecution.getMappingProjectId();
final String targetEnti... | java |
public static Object convert(Object source, Attribute attr) {
try {
return convert(source, attr.getDataType());
} catch (DataConversionException e) {
throw new AttributeValueConversionException(
format(
"Conversion failure in entity type [%s] attribute [%s]; %s",
... | java |
@GetMapping(value = "/{entityTypeId}/exist", produces = APPLICATION_JSON_VALUE)
public boolean entityExists(@PathVariable("entityTypeId") String entityTypeId) {
return dataService.hasRepository(entityTypeId);
} | java |
@GetMapping(value = "/{entityTypeId}/meta", produces = APPLICATION_JSON_VALUE)
public EntityTypeResponse retrieveEntityType(
@PathVariable("entityTypeId") String entityTypeId,
@RequestParam(value = "attributes", required = false) String[] attributes,
@RequestParam(value = "expand", required = false)... | java |
@GetMapping(value = "/{entityTypeId}/{id}", produces = APPLICATION_JSON_VALUE)
public Map<String, Object> retrieveEntity(
@PathVariable("entityTypeId") String entityTypeId,
@PathVariable("id") String untypedId,
@RequestParam(value = "attributes", required = false) String[] attributes,
@Request... | java |
@Transactional
@DeleteMapping("/{entityTypeId}/{id}")
@ResponseStatus(NO_CONTENT)
public void deleteDelete(
@PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId) {
delete(entityTypeId, untypedId);
} | java |
@PostMapping(value = "/{entityTypeId}/{id}", params = "_method=DELETE")
@ResponseStatus(NO_CONTENT)
public void deletePost(
@PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId) {
delete(entityTypeId, untypedId);
} | java |
@DeleteMapping("/{entityTypeId}")
@ResponseStatus(NO_CONTENT)
public void deleteAll(@PathVariable("entityTypeId") String entityTypeId) {
dataService.deleteAll(entityTypeId);
} | java |
@PostMapping(value = "/{entityTypeId}", params = "_method=DELETE")
@ResponseStatus(NO_CONTENT)
public void deleteAllPost(@PathVariable("entityTypeId") String entityTypeId) {
dataService.deleteAll(entityTypeId);
} | java |
@DeleteMapping(value = "/{entityTypeId}/meta")
@ResponseStatus(NO_CONTENT)
public void deleteMeta(@PathVariable("entityTypeId") String entityTypeId) {
deleteMetaInternal(entityTypeId);
} | java |
@PostMapping(value = "/{entityTypeId}/meta", params = "_method=DELETE")
@ResponseStatus(NO_CONTENT)
public void deleteMetaPost(@PathVariable("entityTypeId") String entityTypeId) {
deleteMetaInternal(entityTypeId);
} | java |
@SuppressWarnings("deprecation")
private EntityCollectionResponse retrieveEntityCollectionInternal(
String entityTypeId,
EntityCollectionRequest request,
Set<String> attributesSet,
Map<String, Set<String>> attributeExpandsSet) {
EntityType meta = dataService.getEntityType(entityTypeId);
... | java |
@Bean
public JobFactory<FileIngestJobExecution> fileIngestJobFactory() {
return new JobFactory<FileIngestJobExecution>() {
@Override
public Job createJob(FileIngestJobExecution fileIngestJobExecution) {
final String targetEntityId = fileIngestJobExecution.getTargetEntityId();
final Str... | java |
public static Iterable<String> getAttributeNames(Iterable<Attribute> attrs) {
return () -> stream(attrs).map(Attribute::getName).iterator();
} | java |
public static String buildFullName(Package aPackage, String simpleName) {
String fullName;
if (aPackage != null) {
fullName = aPackage.getId() + PACKAGE_SEPARATOR + simpleName;
} else {
fullName = simpleName;
}
return fullName;
} | java |
private static void checkForKeyword(String name) {
if (KEYWORDS.contains(name) || KEYWORDS.contains(name.toUpperCase())) {
throw new MolgenisDataException(
"Name [" + name + "] is not allowed because it is a reserved keyword.");
}
} | java |
<E extends Entity> void registerStaticEntityFactory(EntityFactory<E, ?> staticEntityFactory) {
String entityTypeId = staticEntityFactory.getEntityTypeId();
staticEntityFactoryMap.put(entityTypeId, staticEntityFactory);
} | java |
private void validateCsvFile(List<String[]> content, String fileName) {
if (content.isEmpty()) {
throw new MolgenisDataException(format("CSV-file: [{0}] is empty", fileName));
}
if (content.size() == 1) {
throw new MolgenisDataException(
format("Header was found, but no data is presen... | java |
public Object eval(String expression, Entity entity, int depth) {
return eval(createBindings(entity, depth), expression);
} | java |
private Object eval(Bindings bindings, String expression) {
try {
return jsScriptEngine.eval(bindings, expression);
} catch (javax.script.ScriptException t) {
return new ScriptException(t.getCause().getMessage(), t.getCause());
} catch (Exception t) {
return new ScriptException(t);
}
... | java |
private Bindings createBindings(Entity entity, int depth) {
Bindings bindings = new SimpleBindings();
JSObject global = (JSObject) magmaBindings.get("nashorn.global");
JSObject magmaScript = (JSObject) global.getMember(KEY_MAGMA_SCRIPT);
JSObject dollarFunction = (JSObject) magmaScript.getMember(KEY_DOL... | java |
private Object toScriptEngineValueMap(Entity entity, int depth) {
if (entity != null) {
Object idValue = toScriptEngineValue(entity, entity.getEntityType().getIdAttribute(), 0);
if (depth == 0) {
return idValue;
} else {
Map<String, Object> map = Maps.newHashMap();
entity
... | java |
private boolean isBroader(AttributeType enrichedTypeGuess, AttributeType columnTypeGuess) {
if (columnTypeGuess == null && enrichedTypeGuess != null || columnTypeGuess == null) {
return true;
}
switch (columnTypeGuess) {
case INT:
return enrichedTypeGuess.equals(INT)
|| enri... | java |
private AttributeType getEnrichedType(AttributeType guess, Object value) {
if (guess == null || value == null) {
return guess;
}
if (guess.equals(STRING)) {
String stringValue = value.toString();
if (stringValue.length() > MAX_STRING_LENGTH) {
return TEXT;
}
if (canVa... | java |
private AttributeType getCommonType(AttributeType existingGuess, AttributeType newGuess) {
if (existingGuess == null && newGuess == null) {
return null;
}
if (existingGuess == null) {
return newGuess;
}
if (newGuess == null) {
return existingGuess;
}
if (existingGuess.eq... | java |
private AttributeType getBasicAttributeType(Object value) {
if (value == null) {
return null;
}
if (value instanceof Integer) {
return INT;
} else if (value instanceof Double || value instanceof Float) {
return DECIMAL;
} else if (value instanceof Long) {
return LONG;
} ... | java |
private void validateDeleteAllowed(Attribute attr) {
String attrIdentifier = attr.getIdentifier();
if (systemEntityTypeRegistry.hasSystemAttribute(attrIdentifier)) {
throw new SystemMetadataModificationException();
}
} | java |
@GetMapping
public String init(
@RequestParam(value = "entity", required = false) String selectedEntityName,
@RequestParam(value = "entityId", required = false) String selectedEntityId,
Model model) {
StringBuilder message = new StringBuilder("");
final boolean currentUserIsSu = SecurityUti... | java |
private EntityType assignUniqueLabel(EntityType entityType, CopyState state) {
Set<String> existingLabels;
Package targetPackage = state.targetPackage();
if (targetPackage != null) {
existingLabels =
stream(targetPackage.getEntityTypes()).map(EntityType::getLabel).collect(toSet());
} els... | java |
public static String getJunctionTableName(
EntityType entityType, Attribute attr, boolean quotedIdentifier) {
int nrAdditionalChars = 1;
String entityPart =
generateId(entityType, (MAX_IDENTIFIER_BYTE_LENGTH - nrAdditionalChars) / 2);
String attrPart = generateId(attr, (MAX_IDENTIFIER_BYTE_LEN... | java |
static String getJunctionTableIndexName(
EntityType entityType, Attribute attr, Attribute idxAttr) {
String indexNamePostfix = "_idx";
int nrAdditionalChars = 1 + indexNamePostfix.length();
String entityPart =
generateId(entityType, (MAX_IDENTIFIER_BYTE_LENGTH - nrAdditionalChars) / 3);
St... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.