List of usage examples for java.math BigInteger ZERO
BigInteger ZERO
To view the source code for java.math BigInteger ZERO.
Click Source Link
From source file:com.rr.wabshs.ui.clients.clientController.java
/** * The 'getActivityLogs.do' GET request will return a list of available activity logs that have saved participants. * /* w ww . j a v a2 s .c o m*/ * @param i The encrypted userId * @param v The encrypted secret * @param programId The clicked program * @return This function will return the program department model * @throws Exception */ @RequestMapping(value = "/activityLogs/getActivityLogs.do", method = RequestMethod.GET) public @ResponseBody ModelAndView getActivityLogs(@RequestParam String i, @RequestParam String v, @RequestParam String j, HttpSession session) throws Exception { ModelAndView mav = new ModelAndView(); mav.setViewName("/clients/participants/pullParticipants"); if (i != null && v != null) { mav.addObject("activityLogId", i); mav.addObject("v", v); mav.addObject("j", j); /* Decrypt the url */ decryptObject decrypt = new decryptObject(); Object obj = decrypt.decryptObject(i, v); String[] result = obj.toString().split((",")); Integer submittedSurveyId = Integer.parseInt(result[0].substring(4)); /* Get a list of completed surveys the logged in user has access to */ User userDetails = (User) session.getAttribute("userDetails"); List<submittedSurveys> activityLogs = new ArrayList<submittedSurveys>(); List<submittedSurveys> submittedSurveys = surveymanager.getActivityLogsForSessionData(userDetails, programId); if (submittedSurveys != null && submittedSurveys.size() > 0) { encryptObject encrypt = new encryptObject(); Map<String, String> map; for (submittedSurveys submittedSurvey : submittedSurveys) { boolean addSubmittedSurvey = false; if (submittedSurvey.getSelectedProgramIds() != null && !"".equals(submittedSurvey.getSelectedProgramIds())) { String submittedSurveyAnswer = surveymanager.getSubmittedSurveyQuestionAnswerByQuestionTag( submittedSurvey.getId(), submittedSurvey.getSurveyId(), "aggregateTracking"); if (submittedSurveyAnswer != null && !"".equals(submittedSurveyAnswer)) { if ("Individual participant".equals(submittedSurveyAnswer) && submittedSurvey.getTotalParticipants().compareTo(BigInteger.ZERO) > 0) { addSubmittedSurvey = true; } } } if (addSubmittedSurvey == true) { //Encrypt the use id to pass in the url map = new HashMap<String, String>(); map.put("id", Integer.toString(submittedSurvey.getId())); map.put("topSecret", topSecret); String[] encrypted = encrypt.encryptObject(map); submittedSurvey.setEncryptedId(encrypted[0]); submittedSurvey.setEncryptedSecret(encrypted[1]); activityLogs.add(submittedSurvey); } } } mav.addObject("activityLogs", activityLogs); } return mav; }
From source file:io.cloudex.cloud.impl.google.GoogleCloudServiceImpl.java
/** * Polls a big data job and once done save the results to a file * @param jobId// w w w . j ava 2 s. com * @param filename * @throws IOException * FIXME rename to saveBigDataResultsToFile */ public QueryStats saveBigQueryResultsToFile(String jobId, Job queryJob, String filename) throws IOException { // query with retry support String completedJob; if (queryJob == null) { completedJob = checkBigQueryJobResults(jobId, true, false); } else { completedJob = queryJob.getJobReference().getJobId(); } Joiner joiner = Joiner.on(','); String pageToken = null; BigInteger totalRows = null; Long totalBytes = null; Integer numFields = null; Stopwatch stopwatch = Stopwatch.createStarted(); try (PrintWriter writer = new PrintWriter(new FileOutputStream(filename))) { do { GetQueryResultsResponse queryResult = this.getQueryResults(completedJob, pageToken); pageToken = queryResult.getPageToken(); log.debug("Page token: " + pageToken); if (totalRows == null) { totalRows = queryResult.getTotalRows(); numFields = queryResult.getSchema().getFields().size(); totalBytes = queryResult.getTotalBytesProcessed(); log.debug("Total rows for query: " + totalRows); } List<TableRow> rows = queryResult.getRows(); if (rows != null) { log.debug("Saving " + rows.size() + ", records to file: " + filename); // save as CSV and properly escape the data to avoid failures on parsing // one field only if (numFields == 1) { for (TableRow row : rows) { writer.println(StringEscapeUtils.escapeCsv((String) row.getF().get(0).getV())); } } else { // multiple fields for (TableRow row : rows) { List<Object> fields = new ArrayList<>(); for (TableCell field : row.getF()) { if (Data.isNull(field.getV())) { fields.add(""); } else { fields.add(StringEscapeUtils.escapeCsv((String) field.getV())); } } writer.println(joiner.join(fields)); } } } } while ((pageToken != null) && !BigInteger.ZERO.equals(totalRows)); } log.debug("BigQuery query data saved successfully, timer: " + stopwatch); QueryStats stats = new QueryStats(totalRows, totalBytes); stats.getOutputFiles().add(filename); return stats; }
From source file:edu.hku.sdb.rewrite.SdbSchemeRewriter.java
/** * Do keyUpdate for a plain text column. * * @param P/* w w w .j a v a 2 s. c o m*/ * @param S * @param targetM * @param targetX * @return */ private Expr keyUpdatePlainCol(Expr P, Expr S, BigInteger targetM, BigInteger targetX) { LOG.debug("Building key update expression for plain column" + P.toSql()); BigInteger pM = BigInteger.ONE; BigInteger pX = BigInteger.ZERO; BigInteger[] pq = SDBEncrypt.keyUpdateClient(pM, targetM, S.getSdbColKey().getM(), pX, targetX, S.getSdbColKey().getX(), prime1, prime2); return buildSdbKeyUpdateExpr(P, S, new BigIntLiteral(pq[0]), new BigIntLiteral(pq[1]), new BigIntLiteral(n), targetM, targetX); }
From source file:edu.hku.sdb.rewrite.SdbSchemeRewriter.java
/** * Do keyUpdate for a plain text column but inverse its value. * * @param P// ww w . j a va2s . co m * @param S * @param targetM * @param targetX * @return */ private Expr keyUpdateInversedPlainCol(Expr P, Expr S, BigInteger targetM, BigInteger targetX) { LOG.debug("Building key update inverse expression for plain column" + P.toSql()); BigInteger pM = n.subtract(BigInteger.ONE); BigInteger pX = BigInteger.ZERO; BigInteger[] pq = SDBEncrypt.keyUpdateClient(pM, targetM, S.getSdbColKey().getM(), pX, targetX, S.getSdbColKey().getX(), prime1, prime2); return buildSdbKeyUpdateExpr(P, S, new BigIntLiteral(pq[0]), new BigIntLiteral(pq[1]), new BigIntLiteral(n), targetM, targetX); }
From source file:com.google.bitcoin.core.Wallet.java
/** * Calls {@link Wallet#commitTx} if tx is not already in the pending pool * * @return true if the tx was added to the wallet, or false if it was already in the pending pool *//*from w w w . ja v a 2 s . c o m*/ public boolean maybeCommitTx(Transaction tx) throws VerificationException { tx.verify(); lock.lock(); try { log.info("!!!! commit START!!! " + tx.getHashAsString()); if (pending.containsKey(tx.getHash())) return false; log.info("commitTx of {}", tx.getHashAsString()); BigInteger balance = getBalance(); tx.setUpdateTime(Utils.now()); // Mark the outputs we're spending as spent so we won't try and use them in future creations. This will also // move any transactions that are now fully spent to the spent map so we can skip them when creating future // spends. updateForSpends(tx, false); // Add to the pending pool. It'll be moved out once we receive this transaction on the best chain. // This also registers txConfidenceListener so wallet listeners get informed. log.info("->pending: {}", tx.getHashAsString()); tx.getConfidence().setConfidenceType(ConfidenceType.PENDING); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.TYPE); addWalletTransaction(Pool.PENDING, tx); /* CSPK-mike START */ // Looking for assets in pending transaction CS.log.info("New tx " + tx.getHash().toString() + " in memory pool"); log.info("!!!! commit HIT!!! " + tx.getHashAsString()); CSTransactionAssets txAssets = new CSTransactionAssets(tx); txAssets.updateAssetBalances(this, 0, CS.getInputAssetBalances(tx)); CS.addToRecentSends(tx); /* CSPK-mike END */ try { BigInteger valueSentFromMe = tx.getValueSentFromMe(this); BigInteger valueSentToMe = tx.getValueSentToMe(this); BigInteger newBalance = balance.add(valueSentToMe).subtract(valueSentFromMe); if (valueSentToMe.compareTo(BigInteger.ZERO) > 0) { checkBalanceFuturesLocked(null); queueOnCoinsReceived(tx, balance, newBalance); } if (valueSentFromMe.compareTo(BigInteger.ZERO) > 0) queueOnCoinsSent(tx, balance, newBalance); maybeQueueOnWalletChanged(); } catch (ScriptException e) { // Cannot happen as we just created this transaction ourselves. throw new RuntimeException(e); } checkState(isConsistent()); informConfidenceListenersIfNotReorganizing(); //saveNow(); } finally { lock.unlock(); } return true; }
From source file:edu.hku.sdb.rewrite.SdbSchemeRewriter.java
/** * TODO: We assume the predicate cannot have columns from different table. * * @param normalBinPred/*from ww w . j a va 2 s . com*/ * @param R * @param S * @return * @throws UnSupportedException */ protected Expr rewriteNorBinPredicate(NormalBinPredicate normalBinPred, Expr R, Expr S) throws UnSupportedException { LOG.debug("Rewriting normal binary predicate " + normalBinPred.toSql()); // No SDB encrypted column. if (!normalBinPred.involveEncrytedCol()) return normalBinPred; Expr leftExpr = normalBinPred.getLeftExpr(); Expr rightExpr = normalBinPred.getRightExpr(); Expr subtractExpr; Expr multiplyExpr; BigInteger targetM = BigInteger.ONE; BigInteger targetX = BigInteger.ZERO; Expr keyUpdateExpr = null; Expr compareExpr = new SdbComparisonExpr(normalBinPred.getOp()); // EE mode if (leftExpr.involveEncrytedCol() && rightExpr.involveEncrytedCol()) { if (leftExpr instanceof NormalArithmeticExpr) { leftExpr = rewriteNorArithExpr((NormalArithmeticExpr) leftExpr, S); } if (rightExpr instanceof NormalArithmeticExpr) { rightExpr = rewriteNorArithExpr((NormalArithmeticExpr) rightExpr, S); } subtractExpr = rewriteSubtractEE(leftExpr, rightExpr, S); multiplyExpr = rewriteMultiplyEE(R, subtractExpr); BigInteger[] pq = SDBEncrypt.keyUpdateClient(multiplyExpr.getSdbColKey().getM(), targetM, S.getSdbColKey().getM(), multiplyExpr.getSdbColKey().getX(), targetX, S.getSdbColKey().getX(), prime1, prime2); keyUpdateExpr = buildSdbKeyUpdateExpr(multiplyExpr, S, new BigIntLiteral(pq[0]), new BigIntLiteral(pq[1]), new BigIntLiteral(n), targetM, targetX); } else if (leftExpr.involveEncrytedCol() || rightExpr.involveEncrytedCol()) { // EC mode if (leftExpr instanceof IntLiteral || leftExpr instanceof FloatLiteral || rightExpr instanceof IntLiteral || rightExpr instanceof FloatLiteral) { if (leftExpr instanceof NormalArithmeticExpr) { leftExpr = rewriteNorArithExpr((NormalArithmeticExpr) leftExpr, S); } if (rightExpr instanceof NormalArithmeticExpr) { rightExpr = rewriteNorArithExpr((NormalArithmeticExpr) rightExpr, S); } subtractExpr = rewriteSubtractEC(leftExpr, rightExpr, S); multiplyExpr = rewriteMultiplyEE(R, subtractExpr); BigInteger[] pq = SDBEncrypt.keyUpdateClient(multiplyExpr.getSdbColKey().getM(), targetM, S.getSdbColKey().getM(), multiplyExpr.getSdbColKey().getX(), targetX, S.getSdbColKey().getX(), prime1, prime2); keyUpdateExpr = buildSdbKeyUpdateExpr(multiplyExpr, S, new BigIntLiteral(pq[0]), new BigIntLiteral(pq[1]), new BigIntLiteral(n), targetM, targetX); } // EP mode else if (leftExpr instanceof FieldLiteral || rightExpr instanceof FieldLiteral) { if (leftExpr instanceof NormalArithmeticExpr) { leftExpr = rewriteNorArithExpr((NormalArithmeticExpr) leftExpr, S); } if (rightExpr instanceof NormalArithmeticExpr) { rightExpr = rewriteNorArithExpr((NormalArithmeticExpr) rightExpr, S); } subtractExpr = rewriteSubtractEP(leftExpr, rightExpr, S); multiplyExpr = rewriteMultiplyEE(R, subtractExpr); BigInteger[] pq = SDBEncrypt.keyUpdateClient(multiplyExpr.getSdbColKey().getM(), targetM, S.getSdbColKey().getM(), multiplyExpr.getSdbColKey().getX(), targetX, S.getSdbColKey().getX(), prime1, prime2); keyUpdateExpr = buildSdbKeyUpdateExpr(multiplyExpr, S, new BigIntLiteral(pq[0]), new BigIntLiteral(pq[1]), new BigIntLiteral(n), targetM, targetX); } } if (normalBinPred.getOp() != BinaryPredicate.BinOperator.EQ) { compareExpr.addChild(keyUpdateExpr); compareExpr.addChild(new BigIntLiteral(n.subtract(BigInteger.ONE).divide(new BigInteger("2")))); } else { compareExpr.addChild(keyUpdateExpr); } return compareExpr; }
From source file:org.sparkbit.jsonrpc.SparkBitJSONRPCServiceImpl.java
private synchronized String sendbitcoinusing_impl(String walletID, String txid, Long vout, String address, Double amount, String message) throws com.bitmechanic.barrister.RpcException { Wallet w = getWalletForWalletName(walletID); if (w == null) { JSONRPCError.WALLET_NOT_FOUND.raiseRpcException(); }/*from ww w . j a v a2 s . c om*/ if (amount <= 0.0) { JSONRPCError.SEND_BITCOIN_AMOUNT_TOO_LOW.raiseRpcException(); } BigInteger bitcoinAmountSatoshis = Utils.toNanoCoins(amount.toString()); // Is the BTC amount more than what is in the wallet? BigInteger totalSpend = bitcoinAmountSatoshis.add(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE); BigInteger availableBalance = w.getBalance(Wallet.BalanceType.AVAILABLE); if (totalSpend.compareTo(availableBalance) > 0) { JSONRPCError.SEND_BITCOIN_INSUFFICIENT_MONEY.raiseRpcException(); } // Does the BTC amount respect the migration fees of any assets? boolean walletHasAnyAssets = CSMiscUtils.walletHasAnyAssets(w); if (walletHasAnyAssets) { boolean migrationSafe = CSMiscUtils.canSafelySpendWhileRespectingMigrationFee(this.controller, w, bitcoinAmountSatoshis); if (!migrationSafe) { BigInteger migrationFee = CSMiscUtils.calcMigrationFeeSatoshis(controller, w); JSONRPCError.SEND_INSUFFICIENT_MONEY_MIGRATION.raiseRpcException( "Need to keep at least " + Utils.bitcoinValueToFriendlyString(migrationFee) + " BTC."); } } // Check send with txid and vout Sha256Hash sendWithTxidHash = null; boolean canSpendSendWithTxOut = false; if (txid != null) { try { sendWithTxidHash = new Sha256Hash(txid); } catch (IllegalArgumentException e) { // Not a valid tx hash string JSONRPCError.INVALID_TXID_HASH.raiseRpcException(); } canSpendSendWithTxOut = isTxOutSpendable(w, sendWithTxidHash, vout.intValue()); } CoinSparkPaymentRef paymentRef = null; String bitcoinAddress = address; if (address.startsWith("s")) { bitcoinAddress = CSMiscUtils.getBitcoinAddressFromCoinSparkAddress(address); if (bitcoinAddress == null) { JSONRPCError.COINSPARK_ADDRESS_INVALID.raiseRpcException(); } else { CoinSparkAddress csa = new CoinSparkAddress(); csa.decode(address); int flags = csa.getAddressFlags(); if ((flags & CoinSparkAddress.COINSPARK_ADDRESS_FLAG_PAYMENT_REFS) > 0) { paymentRef = csa.getPaymentRef(); // log.debug(">>>> CoinSpark address has payment refs flag set: " + paymentRef.toString()); } if (message != null && !CSMiscUtils.canSendTextMessageToCoinSparkAddress(csa)) { JSONRPCError.COINSPARK_ADDRESS_MISSING_TEXT_MESSAGE_FLAG.raiseRpcException(); } } } else { // Cannot send message to a bitcoin address, must be a coinspark address if (message != null) { JSONRPCError.SEND_MESSAGE_MUST_BE_COINSPARK_ADDRESS.raiseRpcException(); } } boolean isValid = CSMiscUtils.validateBitcoinAddress(bitcoinAddress, controller); if (!isValid) { JSONRPCError.BITCOIN_ADDRESS_INVALID.raiseRpcException(); } String filename = getFullPathForWalletName(walletID); final WalletData wd = this.controller.getModel().getPerWalletModelDataByWalletFilename(filename); if (wd.isBusy()) { JSONRPCError.WALLEY_IS_BUSY.raiseRpcException(); } else { wd.setBusy(true); wd.setBusyTaskKey("jsonrpc.busy.sendbitcoin"); this.controller.fireWalletBusyChange(true); } Transaction sendTransaction = null; boolean sendValidated = false; boolean sendSuccessful = false; String sendTxHash = null; try { String sendAmount = amount.toString(); // Create a SendRequest. Address sendAddressObject; sendAddressObject = new Address(controller.getModel().getNetworkParameters(), bitcoinAddress); Wallet.SendRequest sendRequest = Wallet.SendRequest.to(sendAddressObject, Utils.toNanoCoins(sendAmount)); // SendRequest sendRequest = SendRequest.to(sendAddressObject, Utils.toNanoCoins(sendAmount), 6, new BigInteger("10000"),1); sendRequest.ensureMinRequiredFee = true; sendRequest.fee = BigInteger.ZERO; sendRequest.feePerKb = BitcoinModel.SEND_FEE_PER_KB_DEFAULT; // Send with txout vout if (canSpendSendWithTxOut) { boolean addedInput = sendRequest.addInput(w, new CSTransactionOutput(sendWithTxidHash, vout.intValue())); if (!addedInput) { // Failed to add input, so throw exception JSONRPCError.SEND_WITH_TXID_VOUT_FAILED.raiseRpcException(); } } // Send with payment ref - if it exists and is not 0 which SparkBit treats semantically as null if (paymentRef != null && paymentRef.getRef() != 0) { sendRequest.setPaymentRef(paymentRef); } // Set up message if one exists boolean isEmptyMessage = false; if (message == null || message.isEmpty() || message.trim().length() == 0) { isEmptyMessage = true; } if (!isEmptyMessage) { CoinSparkMessagePart[] parts = { CSMiscUtils.createPlainTextCoinSparkMessagePart(message) }; String[] serverURLs = CSMiscUtils.getMessageDeliveryServersArray(this.controller); sendRequest.setMessage(parts, serverURLs); // log.debug(">>>> Messaging servers = " + ArrayUtils.toString(serverURLs)); // log.debug(">>>> parts[0] = " + parts[0]); // log.debug(">>>> parts[0].fileName = " + parts[0].fileName); // log.debug(">>>> parts[0].mimeType = " + parts[0].mimeType); // log.debug(">>>> parts[0].content = " + new String(parts[0].content, "UTF-8")) } // Note - Request is populated with the AES key in the SendBitcoinNowAction after the user has entered it on the SendBitcoinConfirm form. // Complete it (which works out the fee) but do not sign it yet. log.info("Just about to complete the tx (and calculate the fee)..."); w.completeTx(sendRequest, false); sendValidated = true; log.info("The fee after completing the transaction was " + sendRequest.fee); // Let's do it for real now. sendTransaction = this.controller.getMultiBitService().sendCoins(wd, sendRequest, null); if (sendTransaction == null) { // a null transaction returned indicates there was not // enough money (in spite of our validation) JSONRPCError.SEND_BITCOIN_INSUFFICIENT_MONEY.raiseRpcException(); } else { sendSuccessful = true; sendTxHash = sendTransaction.getHashAsString(); log.info("Sent transaction was:\n" + sendTransaction.toString()); } if (sendSuccessful) { // There is enough money. /* If sending assets or BTC to a coinspark address, record transaction id --> coinspark address, into hashmap so we can use when displaying transactions */ if (address.startsWith("s")) { SparkBitMapDB.INSTANCE.putSendCoinSparkAddressForTxid(sendTxHash, address); } } else { // There is not enough money } // } catch (WrongNetworkException e1) { // } catch (AddressFormatException e1) { // } catch (KeyCrypterException e1) { } catch (InsufficientMoneyException e) { JSONRPCError.SEND_BITCOIN_INSUFFICIENT_MONEY.raiseRpcException(); } catch (CSExceptions.CannotEncode e) { JSONRPCError.SEND_MESSAGE_CANNOT_ENCODE.raiseRpcException(e.getMessage()); } catch (Exception e) { JSONRPCError.throwAsRpcException("Could not send bitcoin due to error", e); } finally { // Save the wallet. try { this.controller.getFileHandler().savePerWalletModelData(wd, false); } catch (WalletSaveException e) { // log.error(e.getMessage(), e); } if (sendSuccessful) { // This returns immediately if rpcsendassettimeout is 0. JSONRPCController.INSTANCE.waitForTxSelectable(sendTransaction); // JSONRPCController.INSTANCE.waitForTxBroadcast(sendTxHash); } // Declare that wallet is no longer busy with the task. wd.setBusyTaskKey(null); wd.setBusy(false); this.controller.fireWalletBusyChange(false); } if (sendSuccessful) { controller.fireRecreateAllViews(false); } return sendTxHash; }
From source file:com.sdcs.courierbooking.service.UserServiceImpl.java
@Override public String updatedelBoyBooking(String rnumber, String content, String type, String userId, String name, String contact, String address, String defaultAmount, String status, String codAmount, double latitude, double longitude) { JSONObject delBoyBooking = new JSONObject(); long insertBooking = userDao.updatedelBoyBooking(rnumber, content, type, userId, name, contact, address, defaultAmount, status, codAmount, latitude, longitude); if (insertBooking > 0) { delBoyBooking.put("status", true); delBoyBooking.put("tracking_id", insertBooking); String strSmsText = "%20The%20delivery%20boy%20booking%20has%20been%20confirmed.The%20consignment%20will%20be%20picked%20soon.The%20order%20id%20is%20" + insertBooking + ".Thank%20you%20for%20using%20SDCS.ME.%20"; SdcsSMSComponent.sendSms(contact, strSmsText); String strSmsTexta = "A%20new%20delivery%20boy%20booking%20is%20done%20from%20" + name + ".%20Reference%20id%20is%20" + insertBooking + ".Contact%20number%20is%20" + contact + "."; SdcsSMSComponent.sendSms("9535337626", strSmsTexta); SdcsSMSComponent.sendSms("7411791422", strSmsTexta); SdcsSMSComponent.sendSms("9916168585", strSmsTexta); SdcsEmailComponent/*from w ww. j av a 2 s .c o m*/ .sendMail("chandusc128@gmail.com", "Delivery Boy Booking confirmation", "A new order from " + name + " with booking id" + insertBooking + ". Pick up Address is from " + address + " and contactNumber is " + contact, BigInteger.ZERO); try { sendNotifications(address); } catch (IOException e) { System.out.println("Exception in while sending notification"); } } else { delBoyBooking.put("status", false); } return delBoyBooking.toString(); }
From source file:org.alfresco.opencmis.CMISConnector.java
public ObjectList getObjectRelationships(NodeRef nodeRef, RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions, BigInteger maxItems, BigInteger skipCount) {/*from ww w . ja v a2s.co m*/ ObjectListImpl result = new ObjectListImpl(); result.setHasMoreItems(false); result.setNumItems(BigInteger.ZERO); result.setObjects(new ArrayList<ObjectData>()); if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL)) { // relationships from and to versions are not preserved return result; } // get relationships List<AssociationRef> assocs = new ArrayList<AssociationRef>(); if (relationshipDirection == RelationshipDirection.SOURCE || relationshipDirection == RelationshipDirection.EITHER) { assocs.addAll(nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL)); } if (relationshipDirection == RelationshipDirection.TARGET || relationshipDirection == RelationshipDirection.EITHER) { assocs.addAll(nodeService.getSourceAssocs(nodeRef, RegexQNamePattern.MATCH_ALL)); } int skip = (skipCount == null ? 0 : skipCount.intValue()); int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue()); int counter = 0; boolean hasMore = false; if (max > 0) { // filter relationships that not map the CMIS domain model for (AssociationRef assocRef : assocs) { TypeDefinitionWrapper assocTypeDef = getOpenCMISDictionaryService() .findAssocType(assocRef.getTypeQName()); if (assocTypeDef == null || getType(assocRef.getSourceRef()) == null || getType(assocRef.getTargetRef()) == null) { continue; } if ((typeId != null) && !assocTypeDef.getTypeId().equals(typeId)) { continue; } counter++; if (skip > 0) { skip--; continue; } max--; if (max > 0) { try { result.getObjects() .add(createCMISObject(createNodeInfo(assocRef), filter, includeAllowableActions, IncludeRelationships.NONE, RENDITION_NONE, false, false/*, cmisVersion*/)); } catch (CmisObjectNotFoundException e) { // ignore objects that have not been found (perhaps because their type is unknown to CMIS) } } else { hasMore = true; } } } result.setNumItems(BigInteger.valueOf(counter)); result.setHasMoreItems(hasMore); return result; }
From source file:edu.hku.sdb.rewrite.SdbSchemeRewriter.java
protected Expr rewriteAddEEFast(Expr leftExpr, Expr rightExpr, BigInteger targetM) throws UnSupportedException { assert (leftExpr.involveEncrytedCol() && rightExpr.involveEncrytedCol()); BigInteger targetX = BigInteger.ZERO; SdbArithmeticExpr sdbArithmeticExpr = new SdbArithmeticExpr(SdbOperator.SDB_ADD); // BigInteger targetM = SDBEncrypt.generatePositiveRand(prime1, prime2); // BigInteger targetX = BigInteger.ZERO; //// www.ja va 2 s . c om // FieldLiteral eLiteral = (FieldLiteral) E; // FieldLiteral pLiteral = (FieldLiteral) P; // // FieldLiteral eS = new FieldLiteral(eLiteral.getTblName(), // ColumnDefinition // .S_COLUMN_NAME,DataType.INT); // FieldLiteral pS = new FieldLiteral(pLiteral.getTblName(), // ColumnDefinition // .S_COLUMN_NAME,DataType.INT); // // String key1 = eLiteral.getTblName() + ColumnDefinition.S_COLUMN_NAME; // String key2 = pLiteral.getTblName() + ColumnDefinition.S_COLUMN_NAME; // if(colKeyMap.containsKey(key1)) { // eS.setSdbColKey(colKeyMap.get(key1)); // } // else { // ColumnKey sdbColKey = getTableColumnKey(eLiteral.getTblName(), // ColumnDefinition.S_COLUMN_NAME); // eS.setSdbColKey(sdbColKey); // colKeyMap.put(key1, sdbColKey); // } // // if(colKeyMap.containsKey(key2)){ // pS.setSdbColKey(colKeyMap.get(key2)); // } // else { // ColumnKey sdbColKey = getTableColumnKey(pLiteral.getTblName(), // ColumnDefinition.S_COLUMN_NAME); // pS.setSdbColKey(sdbColKey); // colKeyMap.put(key2, sdbColKey); // } // // Expr pKeyUp = keyUpdatePlainCol(P, pS, targetM, targetX); // // BigInteger[] pq = SDBEncrypt.keyUpdateClient(E.getSdbColKey().getM(), // targetM, eS.getSdbColKey().getX(), E.getSdbColKey().getX(), targetX, // S.getSdbColKey().getX(), prime1, prime2); // // Expr eKeyUp = buildSdbKeyUpdateExpr(E, eS, new BigIntLiteral // (pq[0]), // new BigIntLiteral(pq[1]), new BigIntLiteral(n), targetM, // targetX); // // sdbArithmeticExpr.addChild(eKeyUp); // sdbArithmeticExpr.addChild(pKeyUp); // sdbArithmeticExpr.addChild(new BigIntLiteral(n)); // sdbArithmeticExpr.setSdbColKey(new ColumnKey(targetM, targetX)); return sdbArithmeticExpr; }