List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:com.gs.obevo.dist.Main.java
protected ImmutableMap<String, Procedure<String[]>> getCommandMap() { MutableMap<String, Procedure<String[]>> commandMap = Maps.mutable.empty(); commandMap.put("deploy", new Procedure<String[]>() { @Override//from w w w . j ava2 s . c om public void value(String[] argSubset) { new DbDeployerMain().start(new ArgsParser().parse(argSubset, new DeployerArgs())); } }); commandMap.put("DBREVENG", new Procedure<String[]>() { @Override public void value(String[] argSubset) { AquaRevengArgs argsObj = new ArgsParser().parse(argSubset, new AquaRevengArgs()); new AquaRevengMain().execute(argsObj); } }); commandMap.put("NEWREVENG", new Procedure<String[]>() { @Override public void value(String[] argSubset) { AquaRevengArgs newArgsObj = new ArgsParser().parse(argSubset, new AquaRevengArgs()); AbstractDdlReveng ddlReveng = newArgsObj.getDbPlatform().getDdlReveng(); ddlReveng.reveng(newArgsObj); } }); commandMap.put("DBREVENGMERGE", new Procedure<String[]>() { @Override public void value(String[] argSubset) { DbFileMergerArgs mergeArgsObj = new ArgsParser().parse(argSubset, new DbFileMergerArgs()); new DbFileMerger().execute(mergeArgsObj); } }); commandMap.put("DBREVENGTABLEMERGE", new Procedure<String[]>() { @Override public void value(String[] argSubset) { DbFileMergerArgs tableMergeArgsObj = new ArgsParser().parse(argSubset, new DbFileMergerArgs()); new TableSyncher().execute(tableMergeArgsObj); } }); commandMap.put("INIT", new Procedure<String[]>() { @Override public void value(String[] argSubset) { new DbDeployerMain().start(new ArgsParser() .parse((String[]) ArrayUtils.add(argSubset, "-performInitOnly"), new DeployerArgs())); } }); commandMap.put("PREVIEW", new Procedure<String[]>() { @Override public void value(String[] argSubset) { new DbDeployerMain().start(new ArgsParser().parse((String[]) ArrayUtils.add(argSubset, "-preview"), new DeployerArgs())); } }); commandMap.put("DBDATACOMPARE", new Procedure<String[]>() { @Override public void value(String[] argSubset) { DbDataComparisonUtil.main(argSubset); } }); return commandMap.toImmutable(); }
From source file:au.org.theark.phenotypic.web.component.phenodataupload.PhenoDataUploadStep1.java
private void initQuestionnaireDdc() { Study study = null;/*ww w . ja va2s .c o m*/ Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null && sessionStudyId > 0) { study = iArkCommonService.getStudy(sessionStudyId); } else { log.error("\n\n\n can't have a null study and see pheno!"); } // Get a list of questionnaires for the subject in context by default PhenoDataSetGroup pfgForStudyCriteria = new PhenoDataSetGroup(); pfgForStudyCriteria.setStudy(study); ArkFunction arkFunction = iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION); pfgForStudyCriteria.setArkFunction(arkFunction); pfgForStudyCriteria.setPublished(true); //make sure that we don't return non-published Questionnaires List<PhenoDataSetGroup> questionnaireList = iPhenotypicService.getPhenoDataSetGroups(pfgForStudyCriteria, 0, Integer.MAX_VALUE); ChoiceRenderer<PhenoDataSetGroup> choiceRenderer = new ChoiceRenderer<PhenoDataSetGroup>("name", "id"); questionnaireDdc = new DropDownChoice<PhenoDataSetGroup>("phenoDataSetGroup", (List<PhenoDataSetGroup>) questionnaireList, choiceRenderer); questionnaireDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { List<PhenoDataSetField> phenoDataSetFields = iPhenotypicService .getAllPhenoDataSetFieldsLinkedToPhenoDataSetFieldGroup(questionnaireDdc.getModelObject()); if (phenoDataSetFields.size() > 0) { downloadTemplateButton.setEnabled(true); for (PhenoDataSetField phenoDataSetField : phenoDataSetFields) { PHENO_COLUMN_NAMES = (String[]) ArrayUtils.add(PHENO_COLUMN_NAMES, phenoDataSetField.getName()); PHENO_COLUMN_DESC = (String[]) ArrayUtils.add(PHENO_COLUMN_DESC, phenoDataSetField.getFieldType().getName().toLowerCase()); } PHENO_TEMPLATE_CELLS2 = createPhenoTemplateCellArray(PHENO_COLUMN_NAMES, PHENO_COLUMN_DESC); PHENO_COLUMN_NAMES = null; PHENO_COLUMN_DESC = null; templatePanel.remove(downloadTemplateButton); initDownloadButton(PHENO_TEMPLATE_CELLS2, questionnaireDdc.getModelObject().getName()); templatePanel.add(downloadTemplateButton); target.add(downloadTemplateButton); target.add(templatePanel); } else { error("The DataSet not having any fields specified."); getWizardForm().onError(target, null); downloadTemplateButton.setEnabled(false); target.add(downloadTemplateButton); } } }); }
From source file:gda.jython.accesscontrol.ProtectedMethodComponent.java
/** * Analyse the given class and add any methods annotated to be protected to the protectedMethods array. * /*w w w.j a v a 2 s . c o m*/ * @param clazz */ @SuppressWarnings("rawtypes") private void analyseClass(Class clazz) { // loop over this classes methods Method[] newMethods = clazz.getMethods(); for (Method thisMethod : newMethods) { if (thisMethod.isAnnotationPresent(gda.jython.accesscontrol.MethodAccessProtected.class) && thisMethod.getAnnotation(MethodAccessProtected.class).isProtected()) { addMethod(thisMethod); } } // loop over the interfaces the class implements Class[] newInterfaces = clazz.getInterfaces(); for (Class thisInterface : newInterfaces) { // if its a new interface (for performance, ensure each interface only looked at once) if (!ArrayUtils.contains(analysedInterfaces, thisInterface)) { analysedInterfaces = (Class[]) ArrayUtils.add(analysedInterfaces, thisInterface); // check if any method in that interface is annotated that it should be protected for (Method method : thisInterface.getMethods()) { if (method.isAnnotationPresent(gda.jython.accesscontrol.MethodAccessProtected.class) && method.getAnnotation(MethodAccessProtected.class).isProtected()) { addMethod(method); } } } } }
From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java
@Override public void update(final Object source, final Object arg) { try {//from w w w.j a v a 2s . c o m if (arg instanceof ScriptControllerLogResults && updateViewLock.tryLock(10, TimeUnit.MILLISECONDS)) { final ScriptControllerLogResults temp = (ScriptControllerLogResults) arg; try { addToKnownScripts(temp.getScriptName()); if (haveSeenBefore(temp)) { if (!results[0].getUniqueID().equals(temp.getUniqueID())) { return; } results[0].setUpdated(temp.getUpdated()); PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { view.getTreeViewer().refresh(results[0]); } }); } else { mapID2Controller.put(temp.getUniqueID(), (ILoggingScriptController) source); results = (ScriptControllerLogResults[]) ArrayUtils .addAll(new ScriptControllerLogResults[] { temp }, results); PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { Object[] expandedElements = view.getTreeViewer().getExpandedElements(); expandedElements = ArrayUtils.add(expandedElements, temp); view.getTreeViewer() .setInput(ScriptControllerLogContentProvider.this.getElements(null)); view.getTreeViewer().refresh(results[0]); view.getTreeViewer().setExpandedElements(expandedElements); } }); } } finally { updateViewLock.unlock(); } } } catch (InterruptedException e) { // ignore as this will only ultimately return to the server } }
From source file:com.exoplatform.social.activity.storage.cache.CachedActivityStorage.java
private String[] remove(String[] mentionerIds, String mentionStr, List<String> addedOrRemovedIds) { for (String mentionerId : mentionerIds) { if (mentionerId.indexOf(mentionStr) != -1) { int numStored = Integer.parseInt(mentionerId.split(MENTION_CHAR)[1]) - 1; if (numStored == 0) { addedOrRemovedIds.add(mentionStr.replace(MENTION_CHAR, "")); return (String[]) ArrayUtils.removeElement(mentionerIds, mentionerId); }//from ww w .j a v a2s .c om mentionerIds = (String[]) ArrayUtils.removeElement(mentionerIds, mentionerId); mentionerIds = (String[]) ArrayUtils.add(mentionerIds, mentionStr + numStored); addedOrRemovedIds.add(mentionStr.replace(MENTION_CHAR, "")); break; } } return mentionerIds; }
From source file:net.mumie.coursecreator.graph.MetaInfos.java
public void addAuthor(int id) { this.authors = ArrayUtils.add(this.authors, id); }
From source file:com.blockwithme.hacktors.Chunk.java
/** Adds an item, using local coordinates. */ public void addItemLocal(final int x, final int y, final Item item) { if (item == null) { throw new IllegalArgumentException("item is null"); }/*www .j ava 2s. co m*/ final int index = index(x, y); if (!ArrayUtils.contains(items[index], item)) { items[index] = (Item[]) ArrayUtils.add(items[index], item); } }
From source file:gda.device.detector.countertimer.TfgEpicsMCACounterTimer.java
/** * @param channel/* ww w . ja v a 2 s. co m*/ * @param epicsMcaName * @throws DeviceException */ @SuppressWarnings("unused") public void setEpicsMcaName(int channel, String epicsMcaName) throws DeviceException { if (channel >= 0 && channel < epicsMcaNameList.size()) { this.extraNames = (String[]) ArrayUtils.add(this.extraNames, epicsMcaName); } }
From source file:com.gisgraphy.domain.repository.OpenStreetMapDao.java
@SuppressWarnings("unchecked") public List<StreetDistance> getNearestAndDistanceFrom(final Point point, final double distance, final int firstResult, final int maxResults, final StreetType streetType, final Boolean oneWay, final String name, final StreetSearchMode streetSearchMode, final boolean includeDistanceField) { if (streetSearchMode == StreetSearchMode.FULLTEXT && !GisgraphyConfig.STREET_SEARCH_FULLTEXT_MODE) { throw new GisgraphyException( "The fulltext mode has been removed in gisgraphy v 3.0 and has been replaced by fulltext webservice with placetype=street. please Consult user guide."); }//from w ww .j av a2 s. c o m if (name != null && streetSearchMode == null) { throw new IllegalArgumentException("streetSearchmode can not be null if name is provided"); } if (point == null && streetSearchMode == StreetSearchMode.CONTAINS) { throw new IllegalArgumentException( "you must specify lat/lng when streetsearchmode = " + StreetSearchMode.CONTAINS); } return (List<StreetDistance>) this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws PersistenceException { Criteria criteria = session.createCriteria(OpenStreetMap.class); List<String> fieldList = IntrospectionHelper.getFieldsAsList(OpenStreetMap.class); ProjectionList projections = ProjectionBean.fieldList(fieldList, false); if (includeDistanceField && point != null) { projections.add( // SpatialProjection.distance_sphere(point, GisFeature.LOCATION_COLUMN_NAME).as( // "distance")); SpatialProjection.distance_pointToLine(point, OpenStreetMap.SHAPE_COLUMN_NAME) .as("distance")); } criteria.setProjection(projections); if (includeDistanceField && point != null) { criteria.addOrder(new ProjectionOrder("distance")); } if (maxResults > 0) { criteria = criteria.setMaxResults(maxResults); } if (firstResult >= 1) { criteria = criteria.setFirstResult(firstResult - 1); } if (point != null) { Polygon polygonBox = GeolocHelper.createPolygonBox(point.getX(), point.getY(), distance); criteria = criteria.add(new IntersectsRestriction(OpenStreetMap.SHAPE_COLUMN_NAME, polygonBox)); } if (name != null) { if (streetSearchMode == StreetSearchMode.CONTAINS) { criteria = criteria.add(Restrictions.isNotNull("name"));//optimisation! criteria = criteria.add( Restrictions.ilike(OpenStreetMap.FULLTEXTSEARCH_PROPERTY_NAME, "%" + name + "%")); //criteria = criteria.add(new PartialWordSearchRestriction(OpenStreetMap.PARTIALSEARCH_VECTOR_COLUMN_NAME, name)); } else if (streetSearchMode == StreetSearchMode.FULLTEXT) { criteria = criteria.add( new FulltextRestriction(OpenStreetMap.FULLTEXTSEARCH_VECTOR_PROPERTY_NAME, name)); } else { throw new NotImplementedException( streetSearchMode + " is not implemented for street search"); } } if (streetType != null) { criteria = criteria.add(Restrictions.eq("streetType", streetType)); } if (oneWay != null) { criteria = criteria.add(Restrictions.eq("oneWay", oneWay)); } criteria.setCacheable(true); // List<Object[]> queryResults =testCriteria.list(); List<?> queryResults = criteria.list(); if (queryResults != null && queryResults.size() != 0) { String[] propertiesNameArray; if (includeDistanceField && point != null) { propertiesNameArray = (String[]) ArrayUtils .add(IntrospectionHelper.getFieldsAsArray(OpenStreetMap.class), "distance"); } else { propertiesNameArray = IntrospectionHelper.getFieldsAsArray(OpenStreetMap.class); } List<StreetDistance> results = ResultTransformerUtil .transformToStreetDistance(propertiesNameArray, queryResults); return results; } else { return new ArrayList<StreetDistance>(); } } }); }
From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java
private void addToKnownScripts(String scriptName) { if (!ArrayUtils.contains(knownScripts, scriptName)) { knownScripts = (String[]) ArrayUtils.add(knownScripts, scriptName); view.updateFilter(knownScripts); }/*from w ww.j a v a 2s.c om*/ }