Example usage for org.apache.commons.lang3 StringUtils isNumeric

List of usage examples for org.apache.commons.lang3 StringUtils isNumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNumeric.

Prototype

public static boolean isNumeric(final CharSequence cs) 

Source Link

Document

Checks if the CharSequence contains only Unicode digits.

Usage

From source file:org.opendatakit.common.android.provider.impl.FormsProviderImpl.java

/**
 * This method removes the entry from the content provider, and also removes
 * any associated files. files: form.xml, [formmd5].formdef, formname
 * {directory}//  ww  w.j  av  a2  s.c o m
 */
@Override
public int delete(Uri uri, String where, String[] whereArgs) {
    List<String> segments = uri.getPathSegments();

    if (segments.size() < 1 || segments.size() > 2) {
        throw new IllegalArgumentException("Unknown URI (incorrect number of segments!) " + uri);
    }

    String appName = segments.get(0);
    ODKFileUtils.verifyExternalStorageAvailability();
    ODKFileUtils.assertDirectoryStructure(appName);
    WebLogger log = WebLogger.getLogger(appName);

    String uriFormId = ((segments.size() == 2) ? segments.get(1) : null);
    boolean isNumericId = StringUtils.isNumeric(uriFormId);

    // Modify the where clause to account for the presence of
    // a form id. Accept either:
    // (1) numeric _ID value
    // (2) string FORM_ID value.
    String whereId;
    String[] whereIdArgs;

    if (uriFormId == null) {
        whereId = where;
        whereIdArgs = whereArgs;
    } else {
        if (TextUtils.isEmpty(where)) {
            whereId = (isNumericId ? FormsColumns._ID : FormsColumns.FORM_ID) + "=?";
            whereIdArgs = new String[1];
            whereIdArgs[0] = uriFormId;
        } else {
            whereId = (isNumericId ? FormsColumns._ID : FormsColumns.FORM_ID) + "=? AND (" + where + ")";
            whereIdArgs = new String[whereArgs.length + 1];
            whereIdArgs[0] = uriFormId;
            for (int i = 0; i < whereArgs.length; ++i) {
                whereIdArgs[i + 1] = whereArgs[i];
            }
        }
    }

    Cursor del = null;
    Integer idValue = null;
    String tableIdValue = null;
    String formIdValue = null;
    HashMap<File, DirType> mediaDirs = new HashMap<File, DirType>();
    try {
        del = this.query(uri, null, whereId, whereIdArgs, null);
        if (del == null) {
            throw new SQLException("FAILED Delete into " + uri + " -- unable to query for existing records");
        }
        del.moveToPosition(-1);
        while (del.moveToNext()) {
            idValue = ODKDatabaseUtils.get().getIndexAsType(del, Integer.class,
                    del.getColumnIndex(FormsColumns._ID));
            tableIdValue = ODKDatabaseUtils.get().getIndexAsString(del,
                    del.getColumnIndex(FormsColumns.TABLE_ID));
            formIdValue = ODKDatabaseUtils.get().getIndexAsString(del,
                    del.getColumnIndex(FormsColumns.FORM_ID));
            File mediaDir = ODKFileUtils.asAppFile(appName, ODKDatabaseUtils.get().getIndexAsString(del,
                    del.getColumnIndex(FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH)));
            mediaDirs.put(mediaDir, (tableIdValue == null) ? DirType.FRAMEWORK : DirType.FORMS);
        }
    } catch (Exception e) {
        log.w(t, "FAILED Delete from " + uri + " -- query for existing row failed: " + e.toString());

        if (e instanceof SQLException) {
            throw (SQLException) e;
        } else {
            throw new SQLException(
                    "FAILED Delete from " + uri + " -- query for existing row failed: " + e.toString());
        }
    } finally {
        if (del != null && !del.isClosed()) {
            del.close();
        }
    }

    SQLiteDatabase db = null;
    int count;
    try {
        db = DatabaseFactory.get().getDatabase(getContext(), appName);
        db.beginTransaction();
        count = db.delete(DatabaseConstants.FORMS_TABLE_NAME, whereId, whereIdArgs);
        db.setTransactionSuccessful();
    } catch (Exception e) {
        e.printStackTrace();
        log.w(t, "Unable to perform deletion " + e.toString());
        return 0;
    } finally {
        if (db != null) {
            db.endTransaction();
            db.close();
        }
    }

    // and attempt to move these directories to the stale forms location
    // so that they do not immediately get rescanned...

    for (HashMap.Entry<File, DirType> entry : mediaDirs.entrySet()) {
        try {
            moveDirectory(appName, entry.getValue(), entry.getKey());
        } catch (IOException e) {
            e.printStackTrace();
            log.e(t, "Unable to move directory " + e.toString());
        }
    }

    if (count == 1) {
        Uri formUri = Uri.withAppendedPath(
                Uri.withAppendedPath(Uri.parse("content://" + getFormsAuthority()), appName), formIdValue);
        getContext().getContentResolver().notifyChange(formUri, null);
        Uri idUri = Uri.withAppendedPath(
                Uri.withAppendedPath(Uri.parse("content://" + getFormsAuthority()), appName),
                Long.toString(idValue));
        getContext().getContentResolver().notifyChange(idUri, null);
    } else {
        getContext().getContentResolver().notifyChange(uri, null);
    }
    return count;
}

From source file:org.opendatakit.common.android.provider.impl.FormsProviderImpl.java

@Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
    List<String> segments = uri.getPathSegments();

    if (segments.size() < 1 || segments.size() > 2) {
        throw new IllegalArgumentException("Unknown URI (incorrect number of segments!) " + uri);
    }//from   w ww .  ja  v  a 2  s. co  m

    String appName = segments.get(0);
    ODKFileUtils.verifyExternalStorageAvailability();
    ODKFileUtils.assertDirectoryStructure(appName);
    WebLogger log = WebLogger.getLogger(appName);

    String uriFormId = ((segments.size() == 2) ? segments.get(1) : null);
    boolean isNumericId = StringUtils.isNumeric(uriFormId);

    // Modify the where clause to account for the presence of
    // a form id. Accept either:
    // (1) numeric _ID value
    // (2) string FORM_ID value.
    String whereId;
    String[] whereIdArgs;

    if (uriFormId == null) {
        whereId = where;
        whereIdArgs = whereArgs;
    } else {
        if (TextUtils.isEmpty(where)) {
            whereId = (isNumericId ? FormsColumns._ID : FormsColumns.FORM_ID) + "=?";
            whereIdArgs = new String[1];
            whereIdArgs[0] = uriFormId;
        } else {
            whereId = (isNumericId ? FormsColumns._ID : FormsColumns.FORM_ID) + "=? AND (" + where + ")";
            whereIdArgs = new String[whereArgs.length + 1];
            whereIdArgs[0] = uriFormId;
            for (int i = 0; i < whereArgs.length; ++i) {
                whereIdArgs[i + 1] = whereArgs[i];
            }
        }
    }

    /*
     * First, find out what records match this query, and if they refer to two
     * or more (formId,formVersion) tuples, then be sure to remove all
     * FORM_MEDIA_PATH references. Otherwise, if they are all for the same
     * tuple, and the update specifies a FORM_MEDIA_PATH, move all the
     * non-matching directories elsewhere.
     */
    Integer idValue = null;
    String tableIdValue = null;
    String formIdValue = null;
    HashMap<File, DirType> mediaDirs = new HashMap<File, DirType>();
    boolean multiset = false;
    Cursor c = null;
    try {
        c = this.query(uri, null, whereId, whereIdArgs, null);
        if (c == null) {
            throw new SQLException(
                    "FAILED Update of " + uri + " -- query for existing row did not return a cursor");
        }
        if (c.getCount() >= 1) {
            FormIdVersion ref = null;
            c.moveToPosition(-1);
            while (c.moveToNext()) {
                idValue = ODKDatabaseUtils.get().getIndexAsType(c, Integer.class,
                        c.getColumnIndex(FormsColumns._ID));
                tableIdValue = ODKDatabaseUtils.get().getIndexAsString(c,
                        c.getColumnIndex(FormsColumns.TABLE_ID));
                formIdValue = ODKDatabaseUtils.get().getIndexAsString(c,
                        c.getColumnIndex(FormsColumns.FORM_ID));
                String tableId = ODKDatabaseUtils.get().getIndexAsString(c,
                        c.getColumnIndex(FormsColumns.TABLE_ID));
                String formId = ODKDatabaseUtils.get().getIndexAsString(c,
                        c.getColumnIndex(FormsColumns.FORM_ID));
                String formVersion = ODKDatabaseUtils.get().getIndexAsString(c,
                        c.getColumnIndex(FormsColumns.FORM_VERSION));
                FormIdVersion cur = new FormIdVersion(tableId, formId, formVersion);

                int appRelativeMediaPathIdx = c.getColumnIndex(FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH);
                String mediaPath = ODKDatabaseUtils.get().getIndexAsString(c, appRelativeMediaPathIdx);
                if (mediaPath != null) {
                    mediaDirs.put(ODKFileUtils.asAppFile(appName, mediaPath),
                            (tableIdValue == null) ? DirType.FRAMEWORK : DirType.FORMS);
                }

                if (ref != null && !ref.equals(cur)) {
                    multiset = true;
                    break;
                } else {
                    ref = cur;
                }
            }
        }
    } catch (Exception e) {
        log.w(t, "FAILED Update of " + uri + " -- query for existing row failed: " + e.toString());

        if (e instanceof SQLException) {
            throw (SQLException) e;
        } else {
            throw new SQLException(
                    "FAILED Update of " + uri + " -- query for existing row failed: " + e.toString());
        }
    } finally {
        if (c != null) {
            c.close();
        }
    }

    if (multiset) {
        // don't let users manually update media path
        // we are referring to two or more (formId,formVersion) tuples.
        if (values.containsKey(FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH)) {
            values.remove(FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH);
        }
    } else if (values.containsKey(FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH)) {
        // we are not a multiset and we are setting the media path
        // try to move all the existing non-matching media paths to
        // somewhere else...
        File mediaPath = ODKFileUtils.asAppFile(appName,
                values.getAsString(FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH));
        for (HashMap.Entry<File, DirType> entry : mediaDirs.entrySet()) {
            File altPath = entry.getKey();
            if (!altPath.equals(mediaPath)) {
                try {
                    moveDirectory(appName, entry.getValue(), altPath);
                } catch (IOException e) {
                    e.printStackTrace();
                    log.e(t, "Attempt to move " + altPath.getAbsolutePath() + " failed: " + e.toString());
                }
            }
        }
        // OK. we have moved the existing form definitions elsewhere. We can
        // proceed with update...
    }

    // ensure that all values are correct and ignore some user-supplied
    // values...
    patchUpValues(appName, values);

    // Make sure that the necessary fields are all set
    if (values.containsKey(FormsColumns.DATE) == true) {
        Date today = new Date();
        String ts = new SimpleDateFormat(getContext().getString(R.string.added_on_date_at_time),
                Locale.getDefault()).format(today);
        values.put(FormsColumns.DISPLAY_SUBTEXT, ts);
    }

    SQLiteDatabase db = null;
    int count;
    try {
        // OK Finally, now do the update...
        db = DatabaseFactory.get().getDatabase(getContext(), appName);
        db.beginTransaction();
        count = db.update(DatabaseConstants.FORMS_TABLE_NAME, values, whereId, whereIdArgs);
        db.setTransactionSuccessful();
    } catch (Exception e) {
        e.printStackTrace();
        log.w(t, "Unable to perform update " + uri);
        return 0;
    } finally {
        if (db != null) {
            db.endTransaction();
            db.close();
        }
    }

    if (count == 1) {
        Uri formUri = Uri.withAppendedPath(
                Uri.withAppendedPath(Uri.parse("content://" + getFormsAuthority()), appName), formIdValue);
        getContext().getContentResolver().notifyChange(formUri, null);
        Uri idUri = Uri.withAppendedPath(
                Uri.withAppendedPath(Uri.parse("content://" + getFormsAuthority()), appName),
                Long.toString(idValue));
        getContext().getContentResolver().notifyChange(idUri, null);
    } else {
        getContext().getContentResolver().notifyChange(uri, null);
    }
    return count;
}

From source file:org.opendatakit.services.forms.provider.FormsProvider.java

private PatchedFilter extractUriFeatures(Uri uri, List<String> segments, String where, String[] whereArgs) {

    PatchedFilter pf = new PatchedFilter();

    if (segments.size() < 1 || segments.size() > 3) {
        throw new IllegalArgumentException("Unknown URI (incorrect number of segments!) " + uri);
    }/*from  ww w.j a v  a 2 s  . com*/

    pf.appName = segments.get(0);
    ODKFileUtils.verifyExternalStorageAvailability();
    ODKFileUtils.assertDirectoryStructure(pf.appName);

    pf.tableId = null;
    pf.formId = null;
    pf.numericFormId = null;
    // assume that we are not dealing with _ID values...
    pf.tableId = ((segments.size() >= 2) ? segments.get(1) : null);
    pf.isNumericFormId = StringUtils.isNumeric(pf.tableId);
    if (pf.isNumericFormId) {
        pf.numericFormId = pf.tableId;
        pf.tableId = null;
        if (segments.size() == 3) {
            // user is trying to mix a /_ID uri with a /tableId/formId uri.
            throw new IllegalArgumentException(
                    "Unknown URI ( _ID cannot be combined with other segments!) " + uri);
        }
    }
    // and handle formId
    pf.formId = ((segments.size() == 3) ? segments.get(2) : null);

    // Modify the where clause to account for the presence of any additional segments
    if (segments.size() == 1) {
        // no segments -- directly use whatever filter the user specified
        pf.whereId = where;
        pf.whereIdArgs = whereArgs;
    } else if (segments.size() == 2) {
        // either a tableId or a numericFormId is specified.
        // combine this filter with the where clause the user supplied.
        if (TextUtils.isEmpty(where)) {
            pf.whereId = (pf.isNumericFormId ? FormsColumns._ID : FormsColumns.TABLE_ID) + "=?";
            pf.whereIdArgs = new String[1];
            pf.whereIdArgs[0] = (pf.isNumericFormId ? pf.numericFormId : pf.tableId);
        } else {
            pf.whereId = (pf.isNumericFormId ? FormsColumns._ID : FormsColumns.TABLE_ID) + "=? AND (" + where
                    + ")";
            pf.whereIdArgs = new String[whereArgs.length + 1];
            pf.whereIdArgs[0] = (pf.isNumericFormId ? pf.numericFormId : pf.tableId);
            System.arraycopy(whereArgs, 0, pf.whereIdArgs, 1, whereArgs.length);
        }
    } else {
        // we have both a tableId and a formId.
        // combine with the filter clause the user supplied.
        if (TextUtils.isEmpty(where)) {
            pf.whereId = FormsColumns.TABLE_ID + "=? AND " + FormsColumns.FORM_ID + "=?";
            pf.whereIdArgs = new String[2];
            pf.whereIdArgs[0] = pf.tableId;
            pf.whereIdArgs[1] = pf.formId;
        } else {
            pf.whereId = FormsColumns.TABLE_ID + "=? AND " + FormsColumns.FORM_ID + "=? AND (" + where + ")";
            pf.whereIdArgs = new String[whereArgs.length + 2];
            pf.whereIdArgs[0] = pf.tableId;
            pf.whereIdArgs[1] = pf.formId;
            System.arraycopy(whereArgs, 0, pf.whereIdArgs, 2, whereArgs.length);
        }
    }

    return pf;
}

From source file:org.opendaylight.genius.itm.cli.ItmCliUtils.java

/**
 * Construct dpn id list./*  www .  j a  va 2  s .  c o  m*/
 *
 * @param dpnIds
 *            the dpn ids
 * @return the list
 */
public static List<BigInteger> constructDpnIdList(final String dpnIds) {
    final List<BigInteger> lstDpnIds = new ArrayList<>();
    if (StringUtils.isNotBlank(dpnIds)) {
        final String[] arrDpnIds = StringUtils.split(dpnIds, ',');
        for (String dpn : arrDpnIds) {
            if (StringUtils.isNumeric(StringUtils.trim(dpn))) {
                lstDpnIds.add(new BigInteger(StringUtils.trim(dpn)));
            } else {
                Preconditions.checkArgument(false, String.format("DPN ID [%s] is not a numeric value.", dpn));
            }
        }
    }
    return lstDpnIds;
}

From source file:org.opendaylight.netvirt.elan.internal.ElanInterfaceManager.java

/**
 * Handle external tunnel state event.// www  .  j  av  a2 s . co m
 *
 * @param externalTunnel
 *            the external tunnel
 * @param intrf
 *            the interface
 * @throws ElanException in case of issues creating the flow objects
 */
public void handleExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf)
        throws ElanException {
    if (!validateExternalTunnelStateEvent(externalTunnel, intrf)) {
        return;
    }
    // dpId/externalNodeId will be available either in source or destination
    // based on the tunnel end point
    BigInteger dpId = null;
    NodeId externalNodeId = null;
    if (StringUtils.isNumeric(externalTunnel.getSourceDevice())) {
        dpId = new BigInteger(externalTunnel.getSourceDevice());
        externalNodeId = new NodeId(externalTunnel.getDestinationDevice());
    } else if (StringUtils.isNumeric(externalTunnel.getDestinationDevice())) {
        dpId = new BigInteger(externalTunnel.getDestinationDevice());
        externalNodeId = new NodeId(externalTunnel.getSourceDevice());
    }
    if (dpId == null || externalNodeId == null) {
        LOG.error("Dp ID / externalNodeId not found in external tunnel {}", externalTunnel);
        return;
    }

    ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
    if (dpnInterfaceLists == null) {
        return;
    }
    List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
    for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
        String elanName = elanDpns.getElanInstanceName();
        ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);

        DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
        if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null
                || dpnInterfaces.getInterfaces().isEmpty()) {
            continue;
        }
        LOG.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);

        setupElanBroadcastGroups(elanInfo, dpId);
        // install L2gwDevices local macs in dpn.
        elanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo, intrf.getName());
        // Install dpn macs on external device
        elanL2GatewayUtils.installDpnMacsInL2gwDevice(elanName, new HashSet<>(dpnInterfaces.getInterfaces()),
                dpId, externalNodeId);
    }
    LOG.info("Handled ExternalTunnelStateEvent for {}", externalTunnel);
}

From source file:org.opendaylight.vpnservice.elan.internal.ElanInterfaceManager.java

/**
 * Handle external tunnel state event.//from  w w w.  ja  v  a  2s  . c o m
 *
 * @param externalTunnel
 *            the external tunnel
 * @param intrf
 *            the interface
 */
public void handleExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) {
    if (!validateExternalTunnelStateEvent(externalTunnel, intrf)) {
        return;
    }
    // dpId/externalNodeId will be available either in source or destination
    // based on the tunnel end point
    BigInteger dpId = null;
    NodeId externalNodeId = null;
    if (StringUtils.isNumeric(externalTunnel.getSourceDevice())) {
        dpId = new BigInteger(externalTunnel.getSourceDevice());
        externalNodeId = new NodeId(externalTunnel.getDestinationDevice());
    } else if (StringUtils.isNumeric(externalTunnel.getDestinationDevice())) {
        dpId = new BigInteger(externalTunnel.getDestinationDevice());
        externalNodeId = new NodeId(externalTunnel.getSourceDevice());
    }
    if (dpId == null || externalNodeId == null) {
        logger.error("Dp ID / externalNodeId not found in external tunnel {}", externalTunnel);
        return;
    }

    ElanDpnInterfaces dpnInterfaceLists = ElanUtils.getElanDpnInterfacesList();
    if (dpnInterfaceLists == null) {
        return;
    }
    List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
    for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
        String elanName = elanDpns.getElanInstanceName();
        ElanInstance elanInfo = ElanUtils.getElanInstanceByName(elanName);

        DpnInterfaces dpnInterfaces = ElanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
        if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null
                || dpnInterfaces.getInterfaces().isEmpty()) {
            continue;
        }
        logger.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);

        setupElanBroadcastGroups(elanInfo, dpId);
        // install L2gwDevices local macs in dpn.
        ElanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo);
        // Install dpn macs on external device
        ElanL2GatewayUtils.installDpnMacsInL2gwDevice(elanName, new HashSet<>(dpnInterfaces.getInterfaces()),
                dpId, externalNodeId);
    }
    logger.info("Handled ExternalTunnelStateEvent for {}", externalTunnel);
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Read an {@link Integer} value from XML.
 *
 * @param value// w w  w.  j  av a2  s . c om
 * XML string
 *
 * @param min
 * minimal value
 *
 * @param max
 * maximal value
 *
 * @return
 * parsed value or null, if the value is invalid
 */
private static Integer parseInteger(String value, Integer min, Integer max) {
    String val = StringUtils.trimToNull(value);
    return (val != null && StringUtils.isNumeric(val)) ? Integer.valueOf(val) : null;
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link String} value into XML output
 * with a valid phone number subscriber part.
 *
 * @param value/*from w  w  w .jav a 2  s. c o  m*/
 * value to write
 *
 * @return
 * XML string
 *
 * @throws IllegalArgumentException
 * if a validation error occured
 */
public static String printPhoneNumberSubscriber(String value) {
    String val = StringUtils.trimToNull(value);

    if (val != null) {
        // sicherstellen, dass am Anfang und Ende ein numerischer Wert steht
        String firstDigit = StringUtils.substring(val, 0, 1);
        String lastDigit = StringUtils.substring(val, val.length() - 1);
        if (!StringUtils.isNumeric(firstDigit) || !StringUtils.isNumeric(lastDigit)) {
            throw new IllegalArgumentException("The provided phone subscriber  '" + value + "' is invalid!");
        }

        // alle nicht numerischen Zeichen durch "-" ersetzen
        val = val.replaceAll("\\D", "-");
        while (val.contains("--")) {
            val = StringUtils.replace(val, "--", "-");
        }
    }

    if (val == null || !val.matches("[\\d][\\d \\-]{0,24}[\\d]")) {
        throw new IllegalArgumentException("The provided phone subscriber  '" + value + "' is invalid!");
    }

    return val;
}

From source file:org.openlmis.core.view.viewmodel.InventoryViewModel.java

public boolean validate(boolean archivedProductMandatoryQuantity) {
    if (archivedProductMandatoryQuantity) {
        valid = !checked || StringUtils.isNumeric(quantity);
    } else {/* www . j  a va 2  s .c o  m*/
        if (LMISApp.getInstance().getFeatureToggleFor(R.bool.feature_lot_management)) {
            valid = !checked || validateLotList() || product.isArchived();
        } else {
            valid = !checked || StringUtils.isNumeric(quantity) || product.isArchived();
        }
    }
    return valid;
}

From source file:org.openlmis.core.view.viewmodel.InventoryViewModel.java

public boolean validatePhysical() {
    if (LMISApp.getInstance().getFeatureToggleFor(R.bool.feature_lot_management)) {
        valid = !checked || (validateLotList() && validateExistingLot()) || product.isArchived();
    } else {//  ww  w  . j av  a  2  s. c o m
        valid = !checked || StringUtils.isNumeric(quantity) || product.isArchived();
    }
    return valid;
}