List of usage examples for org.apache.commons.lang ArrayUtils addAll
public static double[] addAll(double[] array1, double[] array2)
Adds all the elements of the given arrays into a new array.
From source file:com.baasbox.service.user.UserService.java
public static List<ODocument> getUsers(QueryParams criteria, boolean excludeInternal) throws SqlInjectionException { if (excludeInternal) { String where = "user.name not in ?"; if (!StringUtils.isEmpty(criteria.getWhere())) { where += " and (" + criteria.getWhere() + ")"; }// w w w . j av a 2s .c om Object[] params = criteria.getParams(); Object[] injectedParams = new String[] { BBConfiguration.getBaasBoxAdminUsername(), BBConfiguration.getBaasBoxUsername() }; Object[] newParams = ArrayUtils.addAll(new Object[] { injectedParams }, params); criteria.where(where); criteria.params(newParams); } return getUsers(criteria); }
From source file:com.aliyun.odps.mapred.local.MapOutputBuffer.java
public void add(Record key, Record value, int partition) { buffers.get(partition).offer(ArrayUtils.addAll(((WritableRecord) key).toWritableArray().clone(), ((WritableRecord) value).toWritableArray().clone())); }
From source file:io.fabric8.utils.cxf.WebClients.java
public static void configureClientCert(WebClient webClient, String clientCertData, File clientCertFile, String clientKeyData, File clientKeyFile, String clientKeyAlgo, char[] clientKeyPassword) { try {/*from w w w .j a va 2s. c om*/ KeyStore keyStore = createKeyStore(clientCertData, clientCertFile, clientKeyData, clientKeyFile, clientKeyAlgo, clientKeyPassword); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, clientKeyPassword); KeyManager[] keyManagers = keyManagerFactory.getKeyManagers(); HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit(); TLSClientParameters params = conduit.getTlsClientParameters(); if (params == null) { params = new TLSClientParameters(); conduit.setTlsClientParameters(params); } KeyManager[] existingKeyManagers = params.getKeyManagers(); if (!ArrayUtils.isEmpty(existingKeyManagers)) { keyManagers = (KeyManager[]) ArrayUtils.addAll(existingKeyManagers, keyManagers); } params.setKeyManagers(keyManagers); } catch (Exception e) { LOG.error("Could not create key manager for " + clientCertFile + " (" + clientKeyFile + ")", e); } }
From source file:alluxio.cli.AlluxioShell.java
/** * Handles the specified shell command request, displaying usage if the command format is invalid. * * @param argv [] Array of arguments given by the user's input from the terminal * @return 0 if command is successful, -1 if an error occurred */// www . ja v a 2s.c o m public int run(String... argv) { if (argv.length == 0) { printUsage(); return -1; } // Sanity check on the number of arguments String cmd = argv[0]; ShellCommand command = mCommands.get(cmd); if (command == null) { // Unknown command (we didn't find the cmd in our dict) String[] replacementCmd = getReplacementCmd(cmd); if (replacementCmd == null) { System.out.println(cmd + " is an unknown command.\n"); printUsage(); return -1; } // Handle command alias, and print out WARNING message for deprecated cmd. String deprecatedMsg = "WARNING: " + cmd + " is deprecated. Please use " + StringUtils.join(replacementCmd, " ") + " instead."; System.out.println(deprecatedMsg); LOG.warn(deprecatedMsg); String[] replacementArgv = (String[]) ArrayUtils.addAll(replacementCmd, ArrayUtils.subarray(argv, 1, argv.length)); return run(replacementArgv); } String[] args = Arrays.copyOfRange(argv, 1, argv.length); CommandLine cmdline = command.parseAndValidateArgs(args); if (cmdline == null) { printUsage(); return -1; } // Handle the command try { return command.run(cmdline); } catch (Exception e) { System.out.println(e.getMessage()); LOG.error("Error running " + StringUtils.join(argv, " "), e); return -1; } }
From source file:gda.device.detector.xmap.TfgXmap.java
/** * Override DetectorBase to work within scans *///ww w . j a v a 2 s. c o m @Override public Object getPosition() throws DeviceException { Object ob = this.readout(); double[] rois = (double[]) ob; if (slave) return rois; return ArrayUtils.addAll(new double[] { collectionTime }, rois); }
From source file:com.cloud.utils.db.SqlGenerator.java
protected void buildAttributes(Class<?> clazz, String tableName, AttributeOverride[] overrides, boolean embedded, boolean isId) { if (!embedded && clazz.getAnnotation(Entity.class) == null) { // A class designated with the MappedSuperclass annotation can be mapped in the same way as an entity // except that the mappings will apply only to its subclasses since no table exists for the mapped superclass itself if (clazz.getAnnotation(MappedSuperclass.class) != null) { Field[] declaredFields = clazz.getDeclaredFields(); _mappedSuperclassFields = (Field[]) ArrayUtils.addAll(_mappedSuperclassFields, declaredFields); }/*from w w w.j av a2 s . c om*/ return; } Class<?> parent = clazz.getSuperclass(); if (parent != null) { buildAttributes(parent, DbUtil.getTableName(parent), DbUtil.getAttributeOverrides(parent), false, false); } if (!embedded) { _tables.add(clazz); _ids.put(tableName, new ArrayList<Attribute>()); } Field[] fields = clazz.getDeclaredFields(); fields = (Field[]) ArrayUtils.addAll(fields, _mappedSuperclassFields); _mappedSuperclassFields = null; for (Field field : fields) { field.setAccessible(true); TableGenerator tg = field.getAnnotation(TableGenerator.class); if (tg != null) { _generators.put(field.getName(), tg); } if (!DbUtil.isPersistable(field)) { continue; } if (field.getAnnotation(Embedded.class) != null) { _embeddeds.add(field); Class<?> embeddedClass = field.getType(); assert (embeddedClass .getAnnotation(Embeddable.class) != null) : "Class is not annotated with Embeddable: " + embeddedClass.getName(); buildAttributes(embeddedClass, tableName, DbUtil.getAttributeOverrides(field), true, false); continue; } if (field.getAnnotation(EmbeddedId.class) != null) { _embeddeds.add(field); Class<?> embeddedClass = field.getType(); assert (embeddedClass .getAnnotation(Embeddable.class) != null) : "Class is not annotated with Embeddable: " + embeddedClass.getName(); buildAttributes(embeddedClass, tableName, DbUtil.getAttributeOverrides(field), true, true); continue; } Attribute attr = new Attribute(clazz, overrides, field, tableName, embedded, isId); if (attr.getColumnName().equals(GenericDao.REMOVED_COLUMN)) { attr.setTrue(Attribute.Flag.DaoGenerated); attr.setFalse(Attribute.Flag.Insertable); attr.setFalse(Attribute.Flag.Updatable); attr.setTrue(Attribute.Flag.TimeStamp); attr.setFalse(Attribute.Flag.Time); attr.setFalse(Attribute.Flag.Date); attr.setTrue(Attribute.Flag.Nullable); attr.setTrue(Attribute.Flag.Removed); } if (attr.isId()) { List<Attribute> attrs = _ids.get(tableName); attrs.add(attr); } _attributes.add(attr); } }
From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java
private void readAllResultsFromDatabases() { if (controllers == null) { logger.error("No ILoggingScriptController configured in the product plugin_customization.ini file.\n" + "Talk to your Data Acq contact to add a uk.ac.gda.client/gda.loggingscriptcontrollers.to_observe entry"); }/*w w w. j av a 2s .c o m*/ for (ILoggingScriptController controller : controllers) { ScriptControllerLogResults[] thisTable = controller.getTable(); for (ScriptControllerLogResults row : thisTable) { mapID2Controller.put(row.getUniqueID(), controller); } results = (ScriptControllerLogResults[]) ArrayUtils.addAll(thisTable, results); } // recreate the filters knownScripts = new String[] {}; for (ScriptControllerLogResults result : results) { String scriptName = result.getScriptName(); if (!ArrayUtils.contains(knownScripts, scriptName)) { knownScripts = (String[]) ArrayUtils.add(knownScripts, scriptName); view.updateFilter(knownScripts); } } view.updateFilter(knownScripts); orderResultsByTime(); }
From source file:io.cloudslang.engine.partitions.services.PartitionTemplateImpl.java
public void setCallbacks(PartitionCallback... callbacks) { this.callbacks = (PartitionCallback[]) ArrayUtils.addAll(this.callbacks, callbacks); }
From source file:com.earnstone.index.ShardedIndex.java
/** * Constructs a sharded index. It is expected that multiple indexes of the * same indexType are stored in the same column family and will be * differentiated by the index name.// ww w . j a v a2s. co m * * @param indexType * The type of the index to create (this is needed because of * type erasure). * @param comparatorType * The Cassandra columnFamily comparator type. * @param cluster * The running cluster. * @param keyspace * Will verify if the keyspace exists and throws a * IllegalArgumentException if the keyspace doesn't exist. * @param columnFamily * Will verify if the column family exists and throws a * IllegalArgumentException if the column family doesn't exist. * @param name * the name of the index. */ protected ShardedIndex(Cluster cluster, Keyspace keyspace, String columnFamily, byte[] baseIndexKey) { this.cluster = cluster; this.keyspace = keyspace; this.columnFamily = columnFamily; this.baseIndexKey = baseIndexKey; if (!getIndexType().equals(Long.class)) { String msg = "Only indexType of Long.class is currently supported."; log.error(msg); throw new IllegalArgumentException(msg); } KeyspaceDefinition kdef = cluster.describeKeyspace(keyspace.getKeyspaceName()); ColumnFamilyDefinition cdef = null; for (ColumnFamilyDefinition tempDef : kdef.getCfDefs()) { if (tempDef.getName().equals(columnFamily)) { cdef = tempDef; break; } } if (cdef == null) { String msg = "Missing column family '" + columnFamily + "' for keyspace '" + keyspace + "'"; log.error(msg); throw new IllegalArgumentException(msg); } if (!cdef.getColumnType().equals(ColumnType.STANDARD)) { String msg = "Expected column family '" + columnFamily + "' to be ColumnType.STANDARD"; log.error(msg); throw new IllegalArgumentException(msg); } if (!cdef.getComparatorType().equals(getComparatorType())) { String msg = "Expected comparator of type '" + getComparatorType().getClassName() + "', but was '" + cdef.getComparatorType().getClassName() + "' for column family '" + columnFamily + "'"; log.error(msg); throw new IllegalArgumentException(msg); } if (baseIndexKey == null || baseIndexKey.length == 0) { String msg = "Sharded index name cannot be null or empty."; log.error(msg); throw new IllegalArgumentException(msg); } emptyIndexKey = ArrayUtils.addAll(baseIndexKey, ArrayUtils.addAll(getEmptyValue(), Delim)); reloadShardsCache(); }
From source file:esiptestbed.mudrod.recommendation.structure.OHCodeExtractor.java
/** * load code values of giving variables/*w w w . j a va 2 s .c om*/ * * @param es * the Elasticsearch client * @param fields * variables list * @return a map from variable value to code */ public Map<String, Vector> loadFieldsOHEncodeMap(ESDriver es, List<String> fields) { Map<String, Vector> metedataCode = new HashMap<>(); SearchResponse scrollResp = es.getClient().prepareSearch(indexName).setTypes(metadataType) .setScroll(new TimeValue(60000)).setQuery(QueryBuilders.matchAllQuery()).setSize(100).execute() .actionGet(); int fieldnum = fields.size(); OHEncoder coder = new OHEncoder(); while (true) { for (SearchHit hit : scrollResp.getHits().getHits()) { Map<String, Object> metadata = hit.getSource(); String shortname = (String) metadata.get("Dataset-ShortName"); double[] codeArr = null; for (int i = 0; i < fieldnum; i++) { String field = fields.get(i); String code = (String) metadata.get(field + "_code"); String[] values = code.split(","); double[] nums = Stream.of(values).mapToDouble(Double::parseDouble).toArray(); // add weight int arrLen = nums.length; for (int k = 0; k < arrLen; k++) { nums[k] = nums[k] * coder.CategoricalVarWeights.get(field); } codeArr = ArrayUtils.addAll(nums, codeArr); } Vector vec = Vectors.dense(codeArr); metedataCode.put(shortname.toLowerCase(), vec); } scrollResp = es.getClient().prepareSearchScroll(scrollResp.getScrollId()) .setScroll(new TimeValue(600000)).execute().actionGet(); if (scrollResp.getHits().getHits().length == 0) { break; } } return metedataCode; }