List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive
public static boolean[] toPrimitive(Boolean[] array)
Converts an array of object Booleans to primitives.
From source file:org.dspace.authenticate.OpenAMAuthentication.java
protected void loadGroups(Context context, Collection<String> roles, HttpServletRequest request, String email) throws SQLException, AuthorizeException { ArrayList<Integer> currentGroups = new ArrayList<>(); log.info("Number of OpenAM roles received for user " + email + " is " + CollectionUtils.size(roles)); for (String role : roles) { log.info("User " + email + " has OpenAM role " + role); if (dSpaceAdminRole.equals(role)) { final Group admins = Group.findByName(context, ADMINISTRATOR_GROUP); if (admins != null) { currentGroups.add(admins.getID()); if (log.isDebugEnabled()) { log.debug("User " + email + " was added to the " + admins.getName() + " group"); }//from w w w. ja v a 2 s . c o m } else { log.warn(LogManager.getHeader(context, "login", "Could not add user as administrator (group not found)!")); } } else if (role.startsWith(dSpaceRolePrefix)) { final String groupName = role.replaceAll(dSpaceRolePrefix, ""); final Group group = Group.findByName(context, groupName); if (group != null) { currentGroups.add(group.getID()); if (log.isDebugEnabled()) { log.debug("User " + email + " was added to the " + group.getName() + " group"); } } else { log.warn(LogManager.getHeader(context, "login", "Could not add user to group:" + groupName + " (group not found)!")); } } } if (CollectionUtils.isNotEmpty(currentGroups)) { int[] groupIdArray = ArrayUtils.toPrimitive(currentGroups.toArray(new Integer[currentGroups.size()])); request.getSession().setAttribute(SPECIAL_GROUP_REQUEST_ATTRIBUTE, groupIdArray); } }
From source file:org.eclipse.jubula.rc.common.tester.ListTester.java
/** * Drags the passed value.//from ww w . j a va2s. c om * * @param mouseButton the mouseButton. * @param modifier the modifier. * @param value The value to drag * @param operator If regular expressions are used * @param searchType Determines where the search begins ("relative" or "absolute") */ public void rcDragValue(int mouseButton, String modifier, String value, String operator, final String searchType) { DragAndDropHelper dndHelper = DragAndDropHelper.getInstance(); dndHelper.setModifier(modifier); dndHelper.setMouseButton(mouseButton); Integer[] indices = findIndicesOfValues(new String[] { value }, operator, searchType); selectIndices(ArrayUtils.toPrimitive(indices), ClickOptions.create().setClickCount(0), false); pressOrReleaseModifiers(modifier, true); getRobot().mousePress(null, null, mouseButton); }
From source file:org.eclipse.jubula.rc.common.tester.ListTester.java
/** * Drops on the passed value.// ww w.j a va2s .c o m * * @param value The value on which to drop * @param operator If regular expressions are used * @param searchType Determines where the search begins ("relative" or "absolute") * @param delayBeforeDrop the amount of time (in milliseconds) to wait * between moving the mouse to the drop point and * releasing the mouse button */ public void rcDropValue(String value, String operator, final String searchType, int delayBeforeDrop) { DragAndDropHelper dndHelper = DragAndDropHelper.getInstance(); try { Integer[] indices = findIndicesOfValues(new String[] { value }, operator, searchType); selectIndices(ArrayUtils.toPrimitive(indices), ClickOptions.create().setClickCount(0), false); waitBeforeDrop(delayBeforeDrop); } finally { getRobot().mouseRelease(null, null, dndHelper.getMouseButton()); pressOrReleaseModifiers(dndHelper.getModifier(), false); } }
From source file:org.eclipse.jubula.rc.common.tester.ListTester.java
/** * Selects the passed value or enumeration of values. By default, the * enumeration separator is <code>,</code>, but may be changed by * <code>separator</code>./*from ww w . ja va 2 s. c om*/ * @param valueList The value or list of values to select * @param separator The separator, optional * @param operator If regular expressions are used * @param searchType Determines where the search begins ("relative" or "absolute") * @param co the click options to use * @param isExtendSelection Whether this selection extends a previous * selection. */ private void selectValue(String valueList, String separator, String operator, final String searchType, ClickOptions co, final boolean isExtendSelection) { String[] values = null; if (StringConstants.EMPTY.equals(valueList)) { values = new String[1]; values[0] = StringConstants.EMPTY; } else { values = split(valueList, separator); } Integer[] indices = findIndicesOfValues(values, operator, searchType); Arrays.sort(indices); if (!operator.equals(MatchUtil.NOT_EQUALS) && (indices.length < values.length)) { throw new StepExecutionException("One or more values not found of set: " //$NON-NLS-1$ + Arrays.asList(values).toString(), EventFactory.createActionError(TestErrorEvent.NOT_FOUND)); } selectIndices(ArrayUtils.toPrimitive(indices), co, isExtendSelection); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.ListViewAdapter.java
/** {@inheritDoc} **/ public int[] getSelectedIndices() { return EventThreadQueuerJavaFXImpl.invokeAndWait("getSelectedIndices", //$NON-NLS-1$ new Callable<int[]>() { /** {@inheritDoc} **/ public int[] call() throws Exception { ObservableList<Integer> sIndices = getRealComponent().getSelectionModel() .getSelectedIndices(); return ArrayUtils.toPrimitive(sIndices.toArray(new Integer[0])); }//from w w w .jav a2 s . c o m }); }
From source file:org.eclipse.nebula.widgets.nattable.selection.preserve.PreserveSelectionModel.java
@Override public int[] getSelectedColumnPositions() { selectionsLock.readLock().lock();//from w w w . j a v a2s. co m try { Collection<Integer> columnPositions = selections.getColumnPositions(); return ArrayUtils.toPrimitive(columnPositions.toArray(new Integer[columnPositions.size()])); } finally { selectionsLock.readLock().unlock(); } }
From source file:org.eclipse.nebula.widgets.nattable.selection.preserve.PreserveSelectionModel.java
@Override public int[] getFullySelectedColumnPositions(int columnHeight) { selectionsLock.readLock().lock();//from w w w.j a v a2 s . c o m try { List<Integer> fullySelectedColumnPositions = new ArrayList<Integer>(); for (Integer selectedColumn : selections.getColumnPositions()) { if (isColumnPositionFullySelected(selectedColumn, columnHeight)) { fullySelectedColumnPositions.add(selectedColumn); } } return ArrayUtils.toPrimitive( fullySelectedColumnPositions.toArray(new Integer[fullySelectedColumnPositions.size()])); } finally { selectionsLock.readLock().unlock(); } }
From source file:org.eclipse.nebula.widgets.nattable.selection.preserve.PreserveSelectionModel.java
@Override public int[] getFullySelectedRowPositions(int rowWidth) { selectionsLock.readLock().lock();/* ww w. ja va 2s .c o m*/ try { List<Integer> fullySelectedRows = new ArrayList<Integer>(); for (Selections<T>.Row selectedRow : selections.getRows()) { T rowObject = selectedRow.getRowObject(); int rowPosition = getRowPositionByRowObject(rowObject); if (isRowVisible(rowPosition) && isRowPositionFullySelected(rowPosition, rowWidth)) { fullySelectedRows.add(rowPosition); } } Collections.sort(fullySelectedRows); return ArrayUtils.toPrimitive(fullySelectedRows.toArray(new Integer[fullySelectedRows.size()])); } finally { selectionsLock.readLock().unlock(); } }
From source file:org.everit.osgi.balance.ri.BalanceAccountComponent.java
@Override public long[] lockAccounts(final long... accountIds) { if (accountIds == null) { throw new IllegalArgumentException("accountIds cannot be null"); }/*from ww w . java2 s. c o m*/ if (accountIds.length < 1) { throw new IllegalArgumentException("at least one accountId must be provided"); } final Long[] accountIdsToLock = ArrayUtils.toObject(accountIds); List<Long> lockedAccountIds = transactionHelper.mandatory(new Callback<List<Long>>() { @Override public List<Long> execute() { QBalanceAccount qBalanceAccount = QBalanceAccount.balAccount; try (Connection connection = dataSource.getConnection()) { return new SQLQuery(connection, sqlTemplates).from(qBalanceAccount) .where(qBalanceAccount.accountId.in(accountIdsToLock)).forUpdate() .list(qBalanceAccount.accountId); } catch (SQLException e) { throw new RuntimeException(e); } } }); for (long accountId : accountIds) { if (!lockedAccountIds.contains(accountId)) { throw new AccountLockException("failed to lock accountId [" + accountId + "]"); } } return ArrayUtils.toPrimitive(lockedAccountIds.toArray(new Long[] {})); }
From source file:org.geoserver.catalog.CoverageViewReader.java
private GridCoverage2D retainBands(List<Integer> bandIndices, GridCoverage2D coverage, Hints hints) { final ParameterValueGroup param = PROCESSOR.getOperation("SelectSampleDimension").getParameters(); param.parameter("Source").setValue(coverage); final int[] sampleDimensionArray = ArrayUtils .toPrimitive(bandIndices.toArray(new Integer[bandIndices.size()])); param.parameter("SampleDimensions").setValue(sampleDimensionArray); coverage = (GridCoverage2D) PROCESSOR.doOperation(param, hints); return coverage; }