public boolean isPaymentMethodInUse() { boolean paymentMethodInUse = false; for (AccessInfo info : confControllers) { paymentMethodInUse |= info.isPaymentMethod(); } return paymentMethodInUse; }
/** * 创建一条记录 * * @param accessInfo * @return */ public long create(AccessInfo accessInfo) { ContentValues values = new ContentValues(); values.put(AccessInfoColumn.USERID, accessInfo.getUserID()); values.put(AccessInfoColumn.ACCESS_TOKEN, accessInfo.getAccessToken()); values.put(AccessInfoColumn.ACCESS_SECRET, accessInfo.getAccessSecret()); return newsDB.insert(DBHelper.ACCESSLIB_TABLE, null, values); }
/** * 更新 * * @param image * @return */ public boolean update(AccessInfo accessInfo) { ContentValues values = new ContentValues(); values.put(AccessInfoColumn.USERID, accessInfo.getUserID()); values.put(AccessInfoColumn.ACCESS_TOKEN, accessInfo.getAccessToken()); values.put(AccessInfoColumn.ACCESS_SECRET, accessInfo.getAccessSecret()); String whereClause = AccessInfoColumn.USERID + "=" + accessInfo.getUserID(); return newsDB.update(DBHelper.ACCESSLIB_TABLE, values, whereClause, null) > 0; }
protected void replace(OfferAccess link) { boolean updated = false; for (AccessInfo confController : confControllers) { if (confController.getLink().equals(link)) { confController.setLink(link); updated = true; } } if (!updated) { addConfiguration(link); } else { confControllerContainer.setDirty(true); } }
@Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if (addMethods.contains(source)) { AccessMethod method = (AccessMethod) source.getUserObject(); addMethod(ureq, method); } else if (source instanceof FormLink) { FormLink button = (FormLink) source; String cmd = button.getCmd(); if ("delete".equals(cmd)) { AccessInfo infos = (AccessInfo) source.getUserObject(); acService.deleteOffer(infos.getLink().getOffer()); confControllers.remove(infos); } else if ("edit".equals(cmd)) { AccessInfo infos = (AccessInfo) source.getUserObject(); editMethod(ureq, infos); } } super.formInnerEvent(ureq, source, event); }
/** * 获取一条图片记录 * * @param imageID * @return */ public AccessInfo getAccessInfo(String userID) { AccessInfo accessInfo = null; String selection = AccessInfoColumn.USERID + "=" + userID; Cursor cursor = newsDB.query( DBHelper.ACCESSLIB_TABLE, AccessInfoColumn.PROJECTION, selection, null, null, null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); accessInfo = new AccessInfo(); accessInfo.setUserID(cursor.getString(AccessInfoColumn.USERID_COLUMN)); accessInfo.setAccessToken(cursor.getString(AccessInfoColumn.ACCESS_TOKEN_COLUMN)); accessInfo.setAccessSecret(cursor.getString(AccessInfoColumn.ACCESS_SECRET_COLUMN)); } return accessInfo; }
/** * 获取全部AccessInfo信息 * * @return */ public ArrayList<AccessInfo> getAccessInfos() { ArrayList<AccessInfo> list = new ArrayList<AccessInfo>(); AccessInfo accessInfo = null; Cursor cursor = newsDB.query( DBHelper.ACCESSLIB_TABLE, AccessInfoColumn.PROJECTION, null, null, null, null, null); if (cursor.getCount() > 0) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { accessInfo = new AccessInfo(); accessInfo.setUserID(cursor.getString(AccessInfoColumn.USERID_COLUMN)); accessInfo.setAccessToken(cursor.getString(AccessInfoColumn.ACCESS_TOKEN_COLUMN)); accessInfo.setAccessSecret(cursor.getString(AccessInfoColumn.ACCESS_SECRET_COLUMN)); list.add(accessInfo); } } cursor.close(); cursor = null; return list; }
public MethodSpec write() { MethodSpec.Builder b = MethodSpec.constructorBuilder(); b.addModifiers(accessInfo.modifiers()); for (ParameterSpec parameterSpec : parameterSpecLIst) { b.addParameter(parameterSpec); } for (CodeBlock codeBlock : codeBlockList) { b.addCode(codeBlock); } return b.build(); }
private void editMethod(UserRequest ureq, AccessInfo infos) { OfferAccess link = infos.getLink(); removeAsListenerAndDispose(editMethodCtrl); AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType()); if (handler != null) { editMethodCtrl = handler.editConfigurationController(ureq, getWindowControl(), link); } if (editMethodCtrl != null) { listenTo(editMethodCtrl); String title = handler.getMethodName(getLocale()); cmc = new CloseableModalController( getWindowControl(), translate("close"), editMethodCtrl.getInitialComponent(), true, title); cmc.activate(); listenTo(cmc); } }
@Override public void formOK(UserRequest ureq) { Map<String, FormItem> formItemMap = confControllerContainer.getFormComponents(); List<OfferAccess> links = new ArrayList<OfferAccess>(); for (AccessInfo info : confControllers) { FormItem dateFrom = formItemMap.get("from_" + info.getLink().getKey()); if (dateFrom instanceof DateChooser) { Date from = ((DateChooser) dateFrom).getDate(); info.getLink().setValidFrom(from); info.getLink().getOffer().setValidFrom(from); } FormItem dateTo = formItemMap.get("to_" + info.getLink().getKey()); if (dateTo instanceof DateChooser) { Date to = ((DateChooser) dateTo).getDate(); info.getLink().setValidTo(to); info.getLink().getOffer().setValidTo(to); } links.add(info.getLink()); } }