code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
@SuppressWarnings("unchecked")
public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) {
try {
return (ObjectInstantiator<T>) constructor.newInstance(type);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new ObjenesisException(e... | java |
public static <T> Class<? super T> getNonSerializableSuperClass(Class<T> type) {
Class<? super T> result = type;
while(Serializable.class.isAssignableFrom(result)) {
result = result.getSuperclass();
if(result == null) {
throw new Error("Bad class hierarchy: No non-serializable ... | java |
public static String describePlatform() {
String desc = "Java " + SPECIFICATION_VERSION + " ("
+ "VM vendor name=\"" + VENDOR + "\", "
+ "VM vendor version=" + VENDOR_VERSION + ", "
+ "JVM name=\"" + JVM_NAME + "\", "
+ "JVM version=" + VM_VERSION + ", "
... | java |
private Map<String, TypeName> convertPropertiesToTypes(Map<String, ExecutableElement> properties) {
Map<String, TypeName> types = new LinkedHashMap<>();
for (Map.Entry<String, ExecutableElement> entry : properties.entrySet()) {
ExecutableElement el = entry.getValue();
types.put(entry.getKey(), TypeN... | java |
private static String classNameOf(TypeElement type, String delimiter) {
String name = type.getSimpleName().toString();
while (type.getEnclosingElement() instanceof TypeElement) {
type = (TypeElement) type.getEnclosingElement();
name = type.getSimpleName() + delimiter + name;
}
return name;
... | java |
public static float[] checkArrayElementsInRange(float[] value, float lower, float upper,
String valueName) {
checkNotNull(value, valueName + " must not be null");
for (int i = 0; i < value.length; ++i) {
float v = value[i];
if... | java |
private void initializeUserStoreAndCheckVersion() throws Exception {
int i = 0;
String version = com.evernote.edam.userstore.Constants.EDAM_VERSION_MAJOR + "."
+ com.evernote.edam.userstore.Constants.EDAM_VERSION_MINOR;
for (String url : mBootstrapServerUrls) {
i++;
try {
Evern... | java |
BootstrapInfoWrapper getBootstrapInfo() throws Exception {
Log.d(LOGTAG, "getBootstrapInfo()");
BootstrapInfo bsInfo = null;
try {
if (mBootstrapServerUsed == null) {
initializeUserStoreAndCheckVersion();
}
bsInfo = mEvernoteSession.getEvernoteClientFactory().getUserStoreClient(ge... | java |
public Response fetchEvernoteUrl(String url) throws IOException {
Request.Builder requestBuilder = new Request.Builder()
.url(url)
.addHeader("Cookie", mAuthHeader)
.get();
return mHttpClient.newCall(requestBuilder.build()).execute();
} | java |
public static String createEnMediaTag(Resource resource) {
return "<en-media hash=\"" + bytesToHex(resource.getData().getBodyHash()) + "\" type=\"" + resource.getMime() + "\"/>";
} | java |
public static byte[] hash(byte[] body) {
if (HASH_DIGEST != null) {
return HASH_DIGEST.digest(body);
} else {
throw new EvernoteUtilException(EDAM_HASH_ALGORITHM + " not supported", new NoSuchAlgorithmException(EDAM_HASH_ALGORITHM));
}
} | java |
public static byte[] hash(InputStream in) throws IOException {
if (HASH_DIGEST == null) {
throw new EvernoteUtilException(EDAM_HASH_ALGORITHM + " not supported", new NoSuchAlgorithmException(EDAM_HASH_ALGORITHM));
}
byte[] buf = new byte[1024];
int n;
while ((n = in.... | java |
public static String bytesToHex(byte[] bytes, boolean withSpaces) {
StringBuilder sb = new StringBuilder();
for (byte hashByte : bytes) {
int intVal = 0xff & hashByte;
if (intVal < 0x10) {
sb.append('0');
}
sb.append(Integer.toHexString(int... | java |
public static byte[] hexToBytes(String hexString) {
byte[] result = new byte[hexString.length() / 2];
for (int i = 0; i < result.length; ++i) {
int offset = i * 2;
result[i] = (byte) Integer.parseInt(hexString.substring(offset,
offset + 2), 16);
}
... | java |
public static void removeAllCookies(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
removeAllCookiesV21();
} else {
removeAllCookiesV14(context.getApplicationContext());
}
} | java |
public static EvernoteInstallStatus getEvernoteInstallStatus(Context context, String action) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(action).setPackage(PACKAGE_NAME);
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, ... | java |
public static Intent createGetBootstrapProfileNameIntent(Context context, EvernoteSession evernoteSession) {
if (evernoteSession.isForceAuthenticationInThirdPartyApp()) {
// we don't want to use the main app, return null
return null;
}
EvernoteUtil.EvernoteInstallStatus ... | java |
public static String generateUserAgentString(Context ctx) {
String packageName = null;
int packageVersion = 0;
try {
packageName = ctx.getPackageName();
packageVersion = ctx.getPackageManager().getPackageInfo(packageName, 0).versionCode;
} catch (PackageManager.N... | java |
public synchronized EvernoteHtmlHelper getHtmlHelperDefault() {
checkLoggedIn();
if (mHtmlHelperDefault == null) {
mHtmlHelperDefault = createHtmlHelper(mEvernoteSession.getAuthToken());
}
return mHtmlHelperDefault;
} | java |
public synchronized EvernoteHtmlHelper getHtmlHelperBusiness() throws TException, EDAMUserException, EDAMSystemException {
if (mHtmlHelperBusiness == null) {
authenticateToBusiness();
mHtmlHelperBusiness = createHtmlHelper(mBusinessAuthenticationResult.getAuthenticationToken());
... | java |
public Note loadNote(boolean withContent, boolean withResourcesData, boolean withResourcesRecognition,
boolean withResourcesAlternateData) throws TException, EDAMUserException, EDAMSystemException, EDAMNotFoundException {
EvernoteNoteStoreClient noteStore = NoteRefHelper.getNoteStore(t... | java |
public synchronized EvernoteClientFactory getEvernoteClientFactory() {
if (mFactoryThreadLocal == null) {
mFactoryThreadLocal = new ThreadLocal<>();
}
if (mEvernoteClientFactoryBuilder == null) {
mEvernoteClientFactoryBuilder = new EvernoteClientFactory.Builder(this);
... | java |
public void authenticate(FragmentActivity activity) {
authenticate(activity, EvernoteLoginFragment.create(mConsumerKey, mConsumerSecret, mSupportAppLinkedNotebooks, mLocale));
} | java |
public synchronized boolean logOut() {
if (!isLoggedIn()) {
return false;
}
mAuthenticationResult.clear();
mAuthenticationResult = null;
EvernoteUtil.removeAllCookies(getApplicationContext());
return true;
} | java |
public T getValue(ModelElementInstance modelElement) {
String value;
if(namespaceUri == null) {
value = modelElement.getAttributeValue(attributeName);
} else {
value = modelElement.getAttributeValueNs(namespaceUri, attributeName);
if(value == null) {
String alternativeNamespace = o... | java |
private Collection<DomElement> getView(ModelElementInstanceImpl modelElement) {
return modelElement.getDomElement().getChildElementsByType(modelElement.getModelInstance(), childElementTypeClass);
} | java |
private void performClearOperation(ModelElementInstanceImpl modelElement, Collection<DomElement> elementsToRemove) {
Collection<ModelElementInstance> modelElements = ModelUtil.getModelElementCollection(elementsToRemove, modelElement.getModelInstance());
for (ModelElementInstance element : modelElements) {
... | java |
@SuppressWarnings("unchecked")
public T getReferenceTargetElement(ModelElementInstance referenceSourceElement) {
String identifier = getReferenceIdentifier(referenceSourceElement);
ModelElementInstance referenceTargetElement = referenceSourceElement.getModelInstance().getModelElementById(identifier);
if (... | java |
public void setReferenceTargetElement(ModelElementInstance referenceSourceElement, T referenceTargetElement) {
ModelInstance modelInstance = referenceSourceElement.getModelInstance();
String referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
ModelElementInstance existingE... | java |
public void referencedElementUpdated(ModelElementInstance referenceTargetElement, String oldIdentifier, String newIdentifier) {
for (ModelElementInstance referenceSourceElement : findReferenceSourceElements(referenceTargetElement)) {
updateReference(referenceSourceElement, oldIdentifier, newIdentifier);
}... | java |
public void referencedElementRemoved(ModelElementInstance referenceTargetElement, Object referenceIdentifier) {
for (ModelElementInstance referenceSourceElement : findReferenceSourceElements(referenceTargetElement)) {
if (referenceIdentifier.equals(getReferenceIdentifier(referenceSourceElement))) {
re... | java |
public static List<String> splitCommaSeparatedList(String text) {
if (text == null || text.isEmpty()) {
return Collections.emptyList();
}
Matcher matcher = pattern.matcher(text);
List<String> parts = new ArrayList<String>();
while(matcher.find()) {
parts.add(matcher.group().trim());
... | java |
private ModelElementInstance findElementToInsertAfter(ModelElementInstance elementToInsert) {
List<ModelElementType> childElementTypes = elementType.getAllChildElementTypes();
List<DomElement> childDomElements = domElement.getChildElements();
Collection<ModelElementInstance> childElements = ModelUtil.getMod... | java |
private void unlinkAllReferences() {
Collection<Attribute<?>> attributes = elementType.getAllAttributes();
for (Attribute<?> attribute : attributes) {
Object identifier = attribute.getValue(this);
if (identifier != null) {
((AttributeImpl<?>) attribute).unlinkReference(this, identifier);
... | java |
private void unlinkAllChildReferences() {
List<ModelElementType> childElementTypes = elementType.getAllChildElementTypes();
for (ModelElementType type : childElementTypes) {
Collection<ModelElementInstance> childElementsForType = getChildElementsByType(type);
for (ModelElementInstance childElement :... | java |
public static DomDocument getEmptyDocument(DocumentBuilderFactory documentBuilderFactory) {
try {
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
return new DomDocumentImpl(documentBuilder.newDocument());
} catch (ParserConfigurationException e) {
throw new Model... | java |
public static DomDocument parseInputStream(DocumentBuilderFactory documentBuilderFactory, InputStream inputStream) {
try {
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilder.setErrorHandler(new DomErrorHandler());
return new DomDocumentImpl(documentBuil... | java |
@SuppressWarnings("unchecked")
public static <T extends ModelElementInstance> Collection<T> getModelElementCollection(Collection<DomElement> view, ModelInstanceImpl model) {
List<ModelElementInstance> resultList = new ArrayList<ModelElementInstance>();
for (DomElement element : view) {
resultList.add(ge... | java |
public static int getIndexOfElementType(ModelElementInstance modelElement, List<ModelElementType> childElementTypes) {
for (int index = 0; index < childElementTypes.size(); index++) {
ModelElementType childElementType = childElementTypes.get(index);
Class<? extends ModelElementInstance> instanceType = c... | java |
public static Collection<ModelElementType> calculateAllExtendingTypes(Model model, Collection<ModelElementType> baseTypes) {
Set<ModelElementType> allExtendingTypes = new HashSet<ModelElementType>();
for (ModelElementType baseType : baseTypes) {
ModelElementTypeImpl modelElementTypeImpl = (ModelElementTyp... | java |
public static Collection<ModelElementType> calculateAllBaseTypes(ModelElementType type) {
List<ModelElementType> baseTypes = new ArrayList<ModelElementType>();
ModelElementTypeImpl typeImpl = (ModelElementTypeImpl) type;
typeImpl.resolveBaseTypes(baseTypes);
return baseTypes;
} | java |
public static void setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance,
String newId, boolean withReferenceUpdate) {
Attribute<?> id = type.getAttribute(ID_ATTRIBUTE_NAME);
if (id != null && id instanceof StringAttribute && id.isIdAttribute()) {
... | java |
public static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, boolean withReferenceUpdate) {
setNewIdentifier(type, modelElementInstance, ModelUtil.getUniqueIdentifier(type), withReferenceUpdate);
} | java |
public static <T> T createInstance(Class<T> type, Object... parameters) {
// get types for parameters
Class<?>[] parameterTypes = new Class<?>[parameters.length];
for (int i = 0; i < parameters.length; i++) {
Object parameter = parameters[i];
parameterTypes[i] = parameter.getClass();
}
... | java |
public void resolveExtendingTypes(Set<ModelElementType> allExtendingTypes) {
for(ModelElementType modelElementType : extendingTypes) {
ModelElementTypeImpl modelElementTypeImpl = (ModelElementTypeImpl) modelElementType;
if (!allExtendingTypes.contains(modelElementTypeImpl)) {
allExtendingTypes.a... | java |
public void resolveBaseTypes(List<ModelElementType> baseTypes) {
if (baseType != null) {
baseTypes.add(baseType);
baseType.resolveBaseTypes(baseTypes);
}
} | java |
public boolean isBaseTypeOf(ModelElementType elementType) {
if (this.equals(elementType)) {
return true;
}
else {
Collection<ModelElementType> baseTypes = ModelUtil.calculateAllBaseTypes(elementType);
return baseTypes.contains(this);
}
} | java |
public Collection<Attribute<?>> getAllAttributes() {
List<Attribute<?>> allAttributes = new ArrayList<Attribute<?>>();
allAttributes.addAll(getAttributes());
Collection<ModelElementType> baseTypes = ModelUtil.calculateAllBaseTypes(this);
for (ModelElementType baseType : baseTypes) {
allAttributes.... | java |
public Attribute<?> getAttribute(String attributeName) {
for (Attribute<?> attribute : getAllAttributes()) {
if (attribute.getAttributeName().equals(attributeName)) {
return attribute;
}
}
return null;
} | java |
private void protectAgainstXxeAttacks(final DocumentBuilderFactory dbf) {
try {
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
} catch (ParserConfigurationException ignored) {
}
try {
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", tru... | java |
public void validateModel(DomDocument document) {
Schema schema = getSchema(document);
if (schema == null) {
return;
}
Validator validator = schema.newValidator();
try {
synchronized(document) {
validator.validate(document.getDomSource());
}
} catch (IOException e) {... | java |
private boolean requiresFullyQualifiedName() {
String currentPackage = PackageScope.get();
if (currentPackage != null) {
if (definition != null && definition.getPackageName() != null && definition.getFullyQualifiedName() != null) {
String conflictingFQCN = getDefinition().get... | java |
@SuppressWarnings("static-method")
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
String prefix = co.returnBaseType != null && co.returnBaseType.contains(".")
? co.returnBaseType.su... | java |
private void checkConstructorArguments(int arguments) {
if (arguments == 0 && (typeDef.getConstructors() == null || typeDef.getConstructors().isEmpty())) {
return;
}
for (Method m : typeDef.getConstructors()) {
int a = m.getArguments() != null ? m.getArguments().size() :... | java |
private void checkFactoryMethodArguments(int arguments) {
for (Method m : typeDef.getMethods()) {
int a = m.getArguments() != null ? m.getArguments().size() : 0;
if (m.getName().equals(staticFactoryMethod) && a == arguments && m.isStatic()) {
return;
}
... | java |
private static boolean classExists(TypeDef typeDef) {
try {
Class.forName(typeDef.getFullyQualifiedName());
return true;
} catch (ClassNotFoundException e) {
return false;
}
} | java |
private static List<Method> adaptConstructors(List<Method> methods, TypeDef target) {
List<Method> adapted = new ArrayList<Method>();
for (Method m : methods) {
adapted.add(new MethodBuilder(m)
.withName(null)
.withReturnType(target.toUnboundedReferenc... | java |
public String getFullyQualifiedName() {
StringBuilder sb = new StringBuilder();
if (packageName != null && !packageName.isEmpty()) {
sb.append(getPackageName()).append(".");
}
if (outerType != null) {
sb.append(outerType.getName()).append(".");
}
... | java |
private static String convertReference(String ref, TypeDef source, TypeDef target, TypeDef targetBuilder) {
StringBuilder sb = new StringBuilder();
sb.append("new ").append(targetBuilder.getName()).append("(").append(convertReference(ref,source,target)).append(")");
return sb.toString();
} | java |
private static String convertMap(String ref, TypeDef source, TypeDef target) {
Method ctor = BuilderUtils.findBuildableConstructor(target);
String arguments = ctor.getArguments().stream()
.map(p -> readMapValue(ref, source, p))
.collect(joining(",\n","\n", ""));
... | java |
private static String readObjectArrayValue(String ref, TypeDef source, Property property) {
StringBuilder sb = new StringBuilder();
Method getter = getterOf(source, property);
TypeRef getterTypeRef = getter.getReturnType();
TypeRef propertyTypeRef = property.getTypeRef();
if (pr... | java |
public static boolean hasMethod(TypeDef typeDef, String method) {
return unrollHierarchy(typeDef)
.stream()
.flatMap(h -> h.getMethods().stream())
.filter(m -> method.equals(m.getName()))
.findAny()
.isPresent();
} | java |
public static boolean hasProperty(TypeDef typeDef, String property) {
return unrollHierarchy(typeDef)
.stream()
.flatMap(h -> h.getProperties().stream())
.filter(p -> property.equals(p.getName()))
.findAny()
.isPresent();
} | java |
public static Set<TypeDef> unrollHierarchy(TypeDef typeDef) {
if (OBJECT.equals(typeDef)) {
return new HashSet<>();
}
Set<TypeDef> hierarchy = new HashSet<>();
hierarchy.add(typeDef);
hierarchy.addAll(typeDef.getExtendsList().stream().flatMap(s -> unrollHierarchy(s.ge... | java |
public Map<Artifact, Dependency> resolve(BomConfig config) throws Exception {
Map<Artifact, Dependency> dependencies = new LinkedHashMap<Artifact, Dependency>();
if (config != null && config.getImports() != null) {
for (BomImport bom : config.getImports()) {
Map<Artifact, Dep... | java |
public static boolean isDescendant(TypeDef item, TypeDef candidate) {
if (item == null || candidate == null) {
return false;
} else if (candidate.isAssignableFrom(item)) {
return true;
}
return false;
} | java |
public static boolean is(Method method, boolean acceptPrefixless) {
int length = method.getName().length();
if (method.isPrivate() || method.isStatic()) {
return false;
}
if (!method.getArguments().isEmpty()) {
return false;
}
if (method.getRetu... | java |
static String readAnyField(Object obj, String ... names) {
try {
for (String name : names) {
try {
Field field = obj.getClass().getDeclaredField(name);
field.setAccessible(true);
return (String) field.get(obj);
... | java |
private static <V,F> Boolean hasCompatibleVisitMethod(V visitor, F fluent) {
for (Method method : visitor.getClass().getMethods()) {
if (!method.getName().equals(VISIT) || method.getParameterTypes().length != 1) {
continue;
}
Class visitorType = method.getPara... | java |
public static final String toPojoName(String name, String prefix, String suffix) {
LinkedList<String> parts = new LinkedList<>(Arrays.asList(name.split(SPLITTER_REGEX)));
if (parts.isEmpty()) {
return prefix + name + suffix;
}
if (parts.getFirst().equals("I")) {
... | java |
public void generatePojos(BuilderContext builderContext, Set<TypeDef> buildables) {
Set<TypeDef> additonalBuildables = new HashSet<>();
Set<TypeDef> additionalTypes = new HashSet<>();
for (TypeDef typeDef : buildables) {
try {
if (typeDef.isInterface() || typeDef.isAn... | java |
public static boolean methodHasArgument(Method method, Property property) {
for (Property candidate : method.getArguments()) {
if (candidate.equals(property)) {
return true;
}
}
return false;
} | java |
public static MortarScope getScope(Context context) {
//noinspection ResourceType
Object scope = context.getSystemService(MORTAR_SERVICE);
if (scope == null) {
// Essentially a workaround for the lifecycle interval where an Activity's
// base context is not yet set to the Application, but the Ap... | java |
public boolean hasService(String serviceName) {
return serviceName.equals(MORTAR_SERVICE) || findService(serviceName, false) != null;
} | java |
public <T> T getService(String serviceName) {
T service = findService(serviceName, true);
if (service == null) {
throw new IllegalArgumentException(format("No service found named \"%s\"", serviceName));
}
return service;
} | java |
private MortarScope searchFromRoot(Scoped scoped)
{
// Ascend to the root.
MortarScope root = this;
while (root.parent != null) {
root = root.parent;
}
// Do the non-recursive search.
List<MortarScope> scopes = new LinkedList<>();
scopes.add(root);
while (!scopes.isEmpty()) {
... | java |
@SuppressWarnings("unchecked") //
public static <T> T getDaggerComponent(Context context) {
//noinspection ResourceType
return (T) context.getSystemService(SERVICE_NAME);
} | java |
public static <T> T createComponent(Class<T> componentClass, Object... dependencies) {
String fqn = componentClass.getName();
String packageName = componentClass.getPackage().getName();
// Accounts for inner classes, ie MyApplication$Component
String simpleName = fqn.substring(packageName.length() + 1)... | java |
static final DocumentFragment createContent(Document doc, String text) {
// [#150] Text might hold XML content, which can be leniently identified by the presence
// of either < or & characters (other entities, like >, ", ' are not stricly XML content)
if (text != null && (text.contains("... | java |
static final String xpath(Element element) {
StringBuilder sb = new StringBuilder();
Node iterator = element;
while (iterator.getNodeType() == Node.ELEMENT_NODE) {
sb.insert(0, "]");
sb.insert(0, siblingIndex((Element) iterator) + 1);
sb.insert(0, "[");
... | java |
static final java.util.Date parseDate(String formatted) {
if (formatted == null || formatted.trim().equals(""))
return null;
try {
DatatypeFactory factory = DatatypeFactory.newInstance();
XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(formatted);
... | java |
Client createClient() throws InterruptedException {
Client client = retryTemplate.execute(this::tryCreateClient);
LOG.info("Connected to Elasticsearch cluster '{}'.", clusterName);
return client;
} | java |
public Ontology getOntology(String iri) {
org.molgenis.ontology.core.meta.Ontology ontology =
dataService
.query(ONTOLOGY, org.molgenis.ontology.core.meta.Ontology.class)
.eq(ONTOLOGY_IRI, iri)
.findOne();
return toOntology(ontology);
} | java |
@SuppressWarnings("squid:S2083")
@PostMapping("/importByUrl")
@ResponseBody
public ResponseEntity<String> importFileByUrl(
HttpServletRequest request,
@RequestParam("url") String url,
@RequestParam(value = "entityTypeId", required = false) String entityTypeId,
@RequestParam(value = "packag... | java |
@PostMapping("/importFile")
public ResponseEntity<String> importFile(
HttpServletRequest request,
@RequestParam(value = "file") MultipartFile file,
@RequestParam(value = "entityTypeId", required = false) String entityTypeId,
@RequestParam(value = "packageId", required = false) String packageId... | java |
public void populate(Entity entity) {
stream(entity.getEntityType().getAllAttributes())
.filter(Attribute::hasDefaultValue)
.forEach(attr -> populateDefaultValues(entity, attr));
} | java |
private Map<String, String> getEnvironmentAttributes() {
Map<String, String> environmentAttributes = new HashMap<>();
environmentAttributes.put(ATTRIBUTE_ENVIRONMENT_TYPE, environment);
return environmentAttributes;
} | java |
public MyEntitiesValidationReport addEntity(String entityTypeId, boolean importable) {
sheetsImportable.put(entityTypeId, importable);
valid = valid && importable;
if (importable) {
fieldsImportable.put(entityTypeId, new ArrayList<>());
fieldsUnknown.put(entityTypeId, new ArrayList<>());
f... | java |
public MyEntitiesValidationReport addAttribute(String attributeName, AttributeState state) {
if (getImportOrder().isEmpty()) {
throw new IllegalStateException("Must add entity first");
}
String entityTypeId = getImportOrder().get(getImportOrder().size() - 1);
valid = valid && state.isValid();
... | java |
private <R> R tryTwice(Supplier<R> action) {
try {
return action.get();
} catch (UnknownIndexException e) {
waitForIndexToBeStable();
try {
return action.get();
} catch (UnknownIndexException e1) {
throw new MolgenisDataException(
format(
"Erro... | java |
private boolean querySupported(Query<Entity> q) {
return !containsAnyOperator(q, unsupportedOperators)
&& !containsComputedAttribute(q, getEntityType())
&& !containsNestedQueryRuleField(q);
} | java |
private void updateEntityTypeEntityWithNewAttributeEntity(
String entity, String attribute, Entity attributeEntity) {
EntityType entityEntity = dataService.getEntityType(entity);
Iterable<Attribute> attributes = entityEntity.getOwnAllAttributes();
entityEntity.set(
ATTRIBUTES,
stream(a... | java |
public FileMeta ingest(
String entityTypeId, String url, String loader, String jobExecutionID, Progress progress) {
if (!"CSV".equals(loader)) {
throw new FileIngestException("Unknown loader '" + loader + "'");
}
progress.setProgressMax(2);
progress.progress(0, "Downloading url '" + url + "... | java |
public static String createId(Entity vcfEntity) {
String idStr =
StringUtils.strip(vcfEntity.get(CHROM).toString())
+ "_"
+ StringUtils.strip(vcfEntity.get(POS).toString())
+ "_"
+ StringUtils.strip(vcfEntity.get(REF).toString())
+ "_"
... | java |
private void updateFailedLoginAttempts(int numberOfAttempts) {
UserSecret userSecret = getSecret();
userSecret.setFailedLoginAttempts(numberOfAttempts);
if (userSecret.getFailedLoginAttempts() >= MAX_FAILED_LOGIN_ATTEMPTS) {
if (!(userSecret.getLastFailedAuthentication() != null
&& (Instant.... | java |
public CompletableFuture<Void> submit(
JobExecution jobExecution, ExecutorService executorService) {
overwriteJobExecutionUser(jobExecution);
Job molgenisJob = saveExecutionAndCreateJob(jobExecution);
Progress progress = jobExecutionRegistry.registerJobExecution(jobExecution);
CompletableFuture<V... | java |
Object executeScript(String jsScript, Map<String, Object> parameters) {
EntityType entityType = entityTypeFactory.create("entity");
Set<String> attributeNames = parameters.keySet();
attributeNames.forEach(key -> entityType.addAttribute(attributeFactory.create().setName(key)));
if (attributeNames.iterato... | java |
public void writeAttributes(Iterable<Attribute> attributes) throws IOException {
List<String> attributeNames = Lists.newArrayList();
List<String> attributeLabels = Lists.newArrayList();
for (Attribute attr : attributes) {
attributeNames.add(attr.getName());
if (attr.getLabel() != null) {
... | java |
@GetMapping
public String viewMappingProjects(Model model) {
model.addAttribute("mappingProjects", mappingService.getAllMappingProjects());
model.addAttribute("entityTypes", getWritableEntityTypes());
model.addAttribute("user", getCurrentUsername());
model.addAttribute("admin", currentUserIsSu());
... | java |
@PostMapping("/addMappingProject")
public String addMappingProject(
@RequestParam("mapping-project-name") String name,
@RequestParam("target-entity") String targetEntity,
@RequestParam("depth") int depth) {
MappingProject newMappingProject = mappingService.addMappingProject(name, targetEntity, d... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.