List of usage examples for java.math BigInteger ONE
BigInteger ONE
To view the source code for java.math BigInteger ONE.
Click Source Link
From source file:org.dvlyyon.net.netconf.Client.java
/** * Returns the next message ID; just one more than the previous one. * * @return new message ID for NETCONF message. *//*from w w w .j a v a 2 s .c o m*/ private synchronized String getNextMessageId() { String ret = "" + m_messageIdTracker; m_messageIdTracker = m_messageIdTracker.add(BigInteger.ONE); return ret; }
From source file:org.apache.juddi.samples.JuddiAdminService.java
void autoMagic() throws Exception { List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList(); Transport transport = clerkManager.getTransport("default"); String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")) .getAuthInfo();/*from w w w. jav a2 s. c o m*/ JUDDIApiPortType juddiApiService = transport.getJUDDIApiService(); System.out.println("fetching..."); ReplicationConfiguration replicationNodes = null; try { replicationNodes = juddiApiService.getReplicationNodes(authtoken); } catch (Exception ex) { System.out.println("Error getting replication config"); ex.printStackTrace(); replicationNodes = new ReplicationConfiguration(); } //if (replicationNodes.getCommunicationGraph() == null) { replicationNodes.setCommunicationGraph(new CommunicationGraph()); //} Operator op = new Operator(); op.setOperatorNodeID("uddi:juddi.apache.org:node1"); op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl()); op.setOperatorStatus(OperatorStatusType.NORMAL); op.getContact().add(new Contact()); op.getContact().get(0).getPersonName().add(new PersonName("bob", "en")); op.getContact().get(0).setUseType("admin"); replicationNodes.getOperator().clear(); replicationNodes.getOperator().add(op); op = new Operator(); op.setOperatorNodeID("uddi:another.juddi.apache.org:node2"); op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2") .getReplicationUrl()); op.setOperatorStatus(OperatorStatusType.NORMAL); op.getContact().add(new Contact()); op.getContact().get(0).getPersonName().add(new PersonName("mary", "en")); op.getContact().get(0).setUseType("admin"); replicationNodes.getOperator().add(op); replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2"); replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1"); replicationNodes.setSerialNumber(0L); replicationNodes.setTimeOfConfigurationUpdate(""); replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE); replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE); if (replicationNodes.getRegistryContact().getContact() == null) { replicationNodes.getRegistryContact().setContact(new Contact()); replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null)); } JAXB.marshal(replicationNodes, System.out); juddiApiService.setReplicationNodes(authtoken, replicationNodes); transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2"); authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo(); juddiApiService = transport.getJUDDIApiService(); juddiApiService.setReplicationNodes(authtoken, replicationNodes); }
From source file:net.pms.util.Rational.java
/** * Returns a {@link Rational} whose value is {@code (this / value)}. * * @param value the value by which this {@link Rational} is to be divided. * @return The division result./*from w w w. j ava 2 s . c o m*/ */ @Nullable public Rational divide(@Nullable BigInteger value) { if (value == null) { return null; } if (isNaN()) { return NaN; } if (value.signum() == 0) { if (signum() == 0) { return NaN; } return signum() > 0 ? POSITIVE_INFINITY : NEGATIVE_INFINITY; } if (signum() == 0 || isInfinite() || BigInteger.ONE.equals(value.abs())) { return value.signum() < 0 ? negate() : this; } // Keep the sign in the numerator and the denominator positive if (value.signum() < 0) { return valueOf(reducedNumerator.negate(), reducedDenominator.multiply(value.negate())); } return valueOf(reducedNumerator, reducedDenominator.multiply(value)); }
From source file:net.sf.json.TestJSONArray.java
public void testToArray_BigInteger() { BigInteger[] expected = new BigInteger[] { BigInteger.ZERO, BigInteger.ONE }; JSONArray jsonArray = JSONArray.fromObject(expected); Object actual = JSONArray.toArray(jsonArray); Assertions.assertEquals(expected, actual); }
From source file:org.apache.juddi.samples.JuddiAdminService.java
void autoMagic3() throws Exception { List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList(); Transport transport = clerkManager.getTransport("default"); String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")) .getAuthInfo();/*w w w . j a v a 2 s.c om*/ JUDDIApiPortType juddiApiService = transport.getJUDDIApiService(); System.out.println("fetching..."); ReplicationConfiguration replicationNodes = null; try { replicationNodes = juddiApiService.getReplicationNodes(authtoken); } catch (Exception ex) { System.out.println("Error getting replication config"); ex.printStackTrace(); replicationNodes = new ReplicationConfiguration(); } if (replicationNodes.getCommunicationGraph() == null) { replicationNodes.setCommunicationGraph(new CommunicationGraph()); } Operator op = new Operator(); op.setOperatorNodeID("uddi:juddi.apache.org:node1"); op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl()); op.setOperatorStatus(OperatorStatusType.NORMAL); op.getContact().add(new Contact()); op.getContact().get(0).getPersonName().add(new PersonName("bob", "en")); op.getContact().get(0).setUseType("admin"); replicationNodes.getOperator().clear(); replicationNodes.getOperator().add(op); op = new Operator(); op.setOperatorNodeID("uddi:another.juddi.apache.org:node2"); op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2") .getReplicationUrl()); op.setOperatorStatus(OperatorStatusType.NORMAL); op.getContact().add(new Contact()); op.getContact().get(0).getPersonName().add(new PersonName("mary", "en")); op.getContact().get(0).setUseType("admin"); replicationNodes.getOperator().add(op); op = new Operator(); op.setOperatorNodeID("uddi:yet.another.juddi.apache.org:node3"); op.setSoapReplicationURL(clerkManager.getClientConfig() .getUDDINode("uddi:yet.another.juddi.apache.org:node3").getReplicationUrl()); op.setOperatorStatus(OperatorStatusType.NORMAL); op.getContact().add(new Contact()); op.getContact().get(0).getPersonName().add(new PersonName("mary", "en")); op.getContact().get(0).setUseType("admin"); replicationNodes.getOperator().add(op); replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2"); replicationNodes.getCommunicationGraph().getNode().add("uddi:yet.another.juddi.apache.org:node3"); replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1"); replicationNodes.setSerialNumber(0L); replicationNodes.setTimeOfConfigurationUpdate(""); replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE); replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE); if (replicationNodes.getRegistryContact().getContact() == null) { replicationNodes.getRegistryContact().setContact(new Contact()); replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null)); } JAXB.marshal(replicationNodes, System.out); juddiApiService.setReplicationNodes(authtoken, replicationNodes); transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2"); authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo(); juddiApiService = transport.getJUDDIApiService(); juddiApiService.setReplicationNodes(authtoken, replicationNodes); transport = clerkManager.getTransport("uddi:yet.another.juddi.apache.org:node3"); authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo(); juddiApiService = transport.getJUDDIApiService(); juddiApiService.setReplicationNodes(authtoken, replicationNodes); }
From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java
@Override public BigInteger rePrintChecksInsert(Motransaction motrans, BigInteger startId, BigInteger endId, BigInteger chekcNo, Integer yearID, Integer periodID, String username) throws BankingException { itsLogger.debug("moTransaction Update"); Session aSession = null;// w ww . j a va2s . c o m /* * Description: MoAccountID is Added to check#. * Table:glLinkage * Reason: fetching Purpose */ BigInteger startId1 = new BigInteger(motrans.getMoAccountId() + "" + startId); BigInteger endId1 = new BigInteger(motrans.getMoAccountId() + "" + endId); GlTransaction aGlTransaction = null; GlTransaction bGlTransaction = null; GlTransaction theGlTransaction = null; String updateQuery = null; //int newCheckValue = chekcNo.intValue(); BigInteger referenceValue = chekcNo; int k = 0; try { Coledgersource aColedgersource = new Coledgersource(); Cofiscalperiod aCofiscalperiod = accountingCyclesService.getCurrentPeriod(periodID); Cofiscalyear aCofiscalyear = accountingCyclesService.getCurrentYear(yearID); aColedgersource = gltransactionService.getColedgersourceDetail("WC"); updateQuery = "SELECT distinct(glTransactionId),vebillID FROM glLinkage WHERE STATUS=0 AND coLedgerSourceId = " + aColedgersource.getCoLedgerSourceId() + " and vebillID BETWEEN " + startId1 + " AND " + endId1; itsLogger.info("Query : " + updateQuery); itsLogger.info("MoAccountID:---->" + motrans.getMoAccountId()); aSession = itsSessionFactory.openSession(); Query insQuery = aSession.createSQLQuery(updateQuery); Iterator<?> theIterator = insQuery.list().iterator(); Transaction aSearchInsert = aSession.beginTransaction(); ArrayList<GlTransaction> glTransactionList = new ArrayList<GlTransaction>(); while (theIterator.hasNext()) { k++; aGlTransaction = new GlTransaction(); theGlTransaction = new GlTransaction(); Object[] aObj = (Object[]) theIterator.next(); aGlTransaction = (GlTransaction) aSession.get(GlTransaction.class, ((Integer) aObj[0])); bGlTransaction = new GlTransaction(); bGlTransaction.setBankClosingBalance(aGlTransaction.getBankClosingBalance()); bGlTransaction.setBankOpeningBalance(aGlTransaction.getBankOpeningBalance()); bGlTransaction.setCoAccountDesc(aGlTransaction.getCoAccountDesc()); bGlTransaction.setCoAccountId(aGlTransaction.getCoAccountId()); bGlTransaction.setCoAccountNumber(aGlTransaction.getCoAccountNumber()); bGlTransaction.setCoFiscalPeriodId(aCofiscalperiod.getCoFiscalPeriodId()); bGlTransaction.setpStartDate(aCofiscalperiod.getStartDate()); bGlTransaction.setpEndDate(aCofiscalperiod.getEndDate()); bGlTransaction.setPeriod(aCofiscalperiod.getPeriod()); bGlTransaction.setCoFiscalYearId(aCofiscalyear.getCoFiscalYearId()); bGlTransaction.setyStartDate(aCofiscalyear.getStartDate()); bGlTransaction.setyStartDate(aCofiscalyear.getEndDate()); bGlTransaction.setFyear(aCofiscalyear.getFiscalYear()); bGlTransaction.setEntrydate(new Date()); bGlTransaction.setEnteredBy(username); bGlTransaction.setTransactionDate(motrans.getTransactionDate()); bGlTransaction.setHiddenstatus(aGlTransaction.getHiddenstatus()); bGlTransaction.setJournalDesc(aGlTransaction.getJournalDesc()); bGlTransaction.setJournalId(aGlTransaction.getJournalId()); bGlTransaction.setOldcoAccountId(aGlTransaction.getOldcoAccountId()); bGlTransaction.setOldcoAccountNumber(aGlTransaction.getOldcoAccountNumber()); bGlTransaction.setStatus(aGlTransaction.getStatus()); bGlTransaction.setTransactionDesc(aGlTransaction.getTransactionDesc()); bGlTransaction.setPoNumber(referenceValue + ""); bGlTransaction.setDebit(aGlTransaction.getDebit()); bGlTransaction.setCredit(aGlTransaction.getCredit()); glTransactionList.add(bGlTransaction); if (k % 2 == 0) { referenceValue = referenceValue.add(BigInteger.ONE); GlRollback glRollback = new GlRollback(); glRollback.setVeBillID((Integer) aObj[1]); glRollback.setCoLedgerSourceID(aColedgersource.getCoLedgerSourceId()); glRollback.setPeriodID(periodID); glRollback.setYearID(yearID); glRollback.setTransactionDate(motrans.getTransactionDate()); gltransactionService.rollBackGlTransaction(glRollback); } itsLogger.info("Reference Val: " + referenceValue); } for (int a = 0; a < glTransactionList.size(); a++) { GlTransaction cGlTransaction = new GlTransaction(); cGlTransaction = glTransactionList.get(a); Integer glID = 0; glID = (Integer) aSession.save(cGlTransaction); glLinkageInsert(aColedgersource, glID, Integer.parseInt(cGlTransaction.getPoNumber()), motrans.getMoAccountId()); } aSearchInsert.commit(); } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; } finally { aSession.flush(); aSession.close(); updateQuery = null; } String aCustomerQry = "SELECT * FROM moTransaction WHERE CAST(reference AS UNSIGNED) BETWEEN " + startId + " AND " + endId + " AND moAccountID=" + motrans.getMoAccountId(); itsLogger.info("Query : " + aCustomerQry); Motransaction aMotransaction = null; Motransaction aMotransactionUpdate = null; MoAccount aMoAccount = null; Query theQuery = null; BigInteger newCheckValue = chekcNo; try { aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aCustomerQry); Iterator<?> aIterator = aQuery.list().iterator(); Transaction aSearchInsert = aSession.beginTransaction(); while (aIterator.hasNext()) { aMotransaction = new Motransaction(); Object[] aObj = (Object[]) aIterator.next(); aMotransaction.setMoTransactionId((Integer) aObj[0]); aMotransactionUpdate = (Motransaction) aSession.get(Motransaction.class, aMotransaction.getMoTransactionId()); theQuery = aSession.createQuery( "From VeBillPaymentHistory where checkNo='" + aMotransactionUpdate.getReference() + "'"); List aList = theQuery.list(); for (int n = 0; n < aList.size(); n++) { VeBillPaymentHistory objph = (VeBillPaymentHistory) aList.get(n); VeBillPaymentHistory objvbillph = (VeBillPaymentHistory) aSession .get(VeBillPaymentHistory.class, objph.getPaymentHistoryID()); objvbillph.setCheckNo(newCheckValue + ""); aSession.save(objvbillph); } aMotransactionUpdate.setReference(newCheckValue + ""); aSession.update(aMotransactionUpdate); newCheckValue = newCheckValue.add(BigInteger.ONE); itsLogger.info("New Check Val: " + newCheckValue); aMoAccount = new MoAccount(); aMoAccount = (MoAccount) aSession.get(MoAccount.class, motrans.getMoAccountId()); aMoAccount.setNextCheckNumber(newCheckValue.intValue()); aSession.update(aMotransactionUpdate); } aSearchInsert.commit(); } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; } /*Session bSession = null; String InsertQry = "INSERT INTO motransaction " + "(rxMasterID,rxAddressID,coAccountID,moAccountId,TransactionDate," + "moTransactionTypeID,CheckType,reference,Description,void,reconciled," + "temprec,printed,amount,directdeposit) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; Motransaction aSearchList = new Motransaction(); try { bSession = itsSessionFactory.openSession(); Transaction aSearchInsert = bSession.beginTransaction(); Query aQuery = bSession.createSQLQuery(InsertQry); for (int i = 0; i < aQueryList.size(); i++) { aSearchList = (Motransaction) aQueryList.get(i); aQuery.setInteger(1, aSearchList.getRxMasterId()); aQuery.setInteger(2, aSearchList.getRxAddressId()); aQuery.setInteger(3, aSearchList.getCoAccountId()); aQuery.setInteger(4, aSearchList.getMoAccountId()); aQuery.setDate(5, aSearchList.getTransactionDate()); aQuery.setInteger(6, aSearchList.getMoTransactionTypeId()); aQuery.setInteger(7, aSearchList.getCheckType()); aQuery.setString(8, newCheckValue+""); aQuery.setString(9, aSearchList.getDescription()); aQuery.setInteger(10, aSearchList.getVoid_()); aQuery.setInteger(11, aSearchList.getReconciled()); aQuery.setInteger(12, aSearchList.getTempRec()); aQuery.setInteger(13, aSearchList.getPrinted()); aQuery.setBigDecimal(14, aSearchList.getAmount()); aQuery.setInteger(15, aSearchList.getDirectDeposit()); bSession.save(aQuery); if (i % 100 == 0) { aSession.flush(); aSession.clear(); Session aTransdetailSession = itsSessionFactory.openSession(); Transaction aTransaction; try { aTransaction = aTransdetailSession.beginTransaction(); aTransaction.begin(); aTransdetailSession.delete(aSearchList); aTransaction.commit(); } catch (Exception excep) { itsLogger.error(excep.getMessage(), excep); BankingException aBankingException = new BankingException(excep.getMessage(), excep); throw aBankingException; } finally { aTransdetailSession.flush(); aTransdetailSession.close(); } } } aSearchInsert.commit(); } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; }*/ finally { aSession.flush(); aSession.close(); aCustomerQry = null; } return newCheckValue; }
From source file:org.nd4j.linalg.util.BigDecimalMath.java
/** * Trigonometric sine./* ww w. java2s .c om*/ * * @param x The argument in radians. * @return sin(x) in the range -1 to 1. */ static public BigDecimal sin(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { return sin(x.negate()).negate(); } else if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else { /* reduce modulo 2pi */ BigDecimal res = mod2pi(x); double errpi = 0.5 * Math.abs(x.ulp().doubleValue()); int val = 2 + err2prec(FastMath.PI, errpi); MathContext mc = new MathContext(val); BigDecimal p = pi(mc); mc = new MathContext(x.precision()); if (res.compareTo(p) > 0) { /* pi<x<=2pi: sin(x)= - sin(x-pi) */ return sin(subtractRound(res, p)).negate(); } else if (res.multiply(new BigDecimal("2")).compareTo(p) > 0) { /* pi/2<x<=pi: sin(x)= sin(pi-x) */ return sin(subtractRound(p, res)); } else { /* for the range 0<=x<Pi/2 one could use sin(2x)=2sin(x)cos(x) * to split this further. Here, use the sine up to pi/4 and the cosine higher up. */ if (res.multiply(new BigDecimal("4")).compareTo(p) > 0) { /* x>pi/4: sin(x) = cos(pi/2-x) */ return cos(subtractRound(p.divide(new BigDecimal("2")), res)); } else { /* Simple Taylor expansion, sum_{i=1..infinity} (-1)^(..)res^(2i+1)/(2i+1)! */ BigDecimal resul = res; /* x^i */ BigDecimal xpowi = res; /* 2i+1 factorial */ BigInteger ifac = BigInteger.ONE; /* The error in the result is set by the error in x itself. */ double xUlpDbl = res.ulp().doubleValue(); /* The error in the result is set by the error in x itself. * We need at most k terms to squeeze x^(2k+1)/(2k+1)! below this value. * x^(2k+1) < x.ulp; (2k+1)*log10(x) < -x.precision; 2k*log10(x)< -x.precision; * 2k*(-log10(x)) > x.precision; 2k*log10(1/x) > x.precision */ int k = (int) (res.precision() / Math.log10(1.0 / res.doubleValue())) / 2; MathContext mcTay = new MathContext(err2prec(res.doubleValue(), xUlpDbl / k)); for (int i = 1;; i++) { /* TBD: at which precision will 2*i or 2*i+1 overflow? */ ifac = ifac.multiply(new BigInteger("" + (2 * i))); ifac = ifac.multiply(new BigInteger("" + (2 * i + 1))); xpowi = xpowi.multiply(res).multiply(res).negate(); BigDecimal corr = xpowi.divide(new BigDecimal(ifac), mcTay); resul = resul.add(corr); if (corr.abs().doubleValue() < 0.5 * xUlpDbl) { break; } } /* The error in the result is set by the error in x itself. */ mc = new MathContext(res.precision()); return resul.round(mc); } } } /* sin */ }
From source file:org.matheclipse.commons.parser.client.eval.bigfraction.BigFractionEvaluator.java
@Override public BigFraction visit(IntegerNode node) { String iStr = ((NumberNode) node).getString(); if (iStr != null) { return new BigFraction(new BigInteger(iStr), BigInteger.ONE); } else {/*from ww w . ja v a 2s .co m*/ return new BigFraction(((IntegerNode) node).getIntValue(), 1); } }
From source file:cz.cas.lib.proarc.common.export.mets.structure.MetsElementVisitor.java
/** * Generates the premis for amdSec/*from w ww .j ava 2 s. c o m*/ * * @param metsElement * @param datastream * @param md5Info * @param created * @param formatVersion * @return * @throws MetsExportException */ private Node getPremisFile(IMetsElement metsElement, String datastream, FileMD5Info md5Info) throws MetsExportException { PremisComplexType premis = new PremisComplexType(); ObjectFactory factory = new ObjectFactory(); JAXBElement<PremisComplexType> jaxbPremix = factory.createPremis(premis); cz.cas.lib.proarc.premis.File file = factory.createFile(); premis.getObject().add(file); ObjectIdentifierComplexType objectIdentifier = new ObjectIdentifierComplexType(); objectIdentifier.setObjectIdentifierType("ProArc_URI"); objectIdentifier.setObjectIdentifierValue( Const.FEDORAPREFIX + metsElement.getOriginalPid() + "/" + Const.dataStreamToModel.get(datastream)); file.getObjectIdentifier().add(objectIdentifier); PreservationLevelComplexType preservation = new PreservationLevelComplexType(); if ("RAW".equals(datastream)) { preservation.setPreservationLevelValue("deleted"); } else { preservation.setPreservationLevelValue("preservation"); } file.getPreservationLevel().add(preservation); ObjectCharacteristicsComplexType characteristics = new ObjectCharacteristicsComplexType(); characteristics.setCompositionLevel(BigInteger.ZERO); file.getObjectCharacteristics().add(characteristics); FixityComplexType fixity = new FixityComplexType(); fixity.setMessageDigest(md5Info.getMd5()); fixity.setMessageDigestAlgorithm("MD5"); fixity.setMessageDigestOriginator("ProArc"); characteristics.getFixity().add(fixity); characteristics.setSize(md5Info.getSize()); FormatComplexType format = new FormatComplexType(); characteristics.getFormat().add(format); FormatDesignationComplexType formatDesignation = new FormatDesignationComplexType(); formatDesignation.setFormatName(md5Info.getMimeType()); formatDesignation.setFormatVersion(md5Info.getFormatVersion()); JAXBElement<FormatDesignationComplexType> jaxbDesignation = factory .createFormatDesignation(formatDesignation); format.getContent().add(jaxbDesignation); FormatRegistryComplexType formatRegistry = new FormatRegistryComplexType(); formatRegistry.setFormatRegistryName("PRONOM"); formatRegistry.setFormatRegistryKey(Const.mimeToFmtMap.get(md5Info.getMimeType())); JAXBElement<FormatRegistryComplexType> jaxbRegistry = factory.createFormatRegistry(formatRegistry); format.getContent().add(jaxbRegistry); CreatingApplicationComplexType creatingApplication = new CreatingApplicationComplexType(); characteristics.getCreatingApplication().add(creatingApplication); creatingApplication.getContent().add(factory.createCreatingApplicationName("ProArc")); creatingApplication.getContent() .add(factory.createCreatingApplicationVersion(metsElement.getMetsContext().getProarcVersion())); creatingApplication.getContent() .add(factory.createDateCreatedByApplication(MetsUtils.getCurrentDate().toXMLFormat())); RelationshipComplexType relationShip = new RelationshipComplexType(); if (!("RAW").equals(datastream)) { relationShip.setRelationshipType("derivation"); relationShip.setRelationshipSubType("created from"); RelatedObjectIdentificationComplexType relatedObject = new RelatedObjectIdentificationComplexType(); relationShip.getRelatedObjectIdentification().add(relatedObject); relatedObject.setRelatedObjectIdentifierType("ProArc_URI"); relatedObject.setRelatedObjectIdentifierValue( Const.FEDORAPREFIX + metsElement.getOriginalPid() + "/" + Const.dataStreamToModel.get("RAW")); RelatedEventIdentificationComplexType eventObject = new RelatedEventIdentificationComplexType(); relationShip.getRelatedEventIdentification().add(eventObject); eventObject.setRelatedEventIdentifierType("ProArc_EventID"); eventObject.setRelatedEventIdentifierValue(Const.dataStreamToEvent.get(datastream)); eventObject.setRelatedEventSequence(BigInteger.ONE); file.getRelationship().add(relationShip); } else { relationShip.setRelationshipType("creation"); relationShip.setRelationshipSubType("created from"); LinkingEventIdentifierComplexType eventIdentifier = new LinkingEventIdentifierComplexType(); file.getLinkingEventIdentifier().add(eventIdentifier); eventIdentifier.setLinkingEventIdentifierType("ProArc_EventID"); eventIdentifier.setLinkingEventIdentifierValue(Const.dataStreamToEvent.get(datastream)); } String originalFile = MetsUtils.xPathEvaluateString(metsElement.getRelsExt(), "*[local-name()='RDF']/*[local-name()='Description']/*[local-name()='importFile']"); OriginalNameComplexType originalName = factory.createOriginalNameComplexType(); originalName.setValue(originalFile); file.setOriginalName(originalName); JAXBContext jc; try { jc = JAXBContext.newInstance(PremisComplexType.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.newDocument(); // Marshal the Object to a Document Marshaller marshaller = jc.createMarshaller(); marshaller.marshal(jaxbPremix, document); XPath xpath = XPathFactory.newInstance().newXPath(); Node premisNode = (Node) xpath.compile("*[local-name()='premis']/*[local-name()='object']") .evaluate(document, XPathConstants.NODE); return premisNode; } catch (Exception e) { throw new MetsExportException(metsElement.getOriginalPid(), "Error while generating premis data", false, e); } }
From source file:energy.usef.core.service.business.CorePlanboardBusinessServiceTest.java
private PTU buildPTU(int i) { PTU ptu = new PTU(); ptu.setStart(BigInteger.valueOf(i)); ptu.setDuration(BigInteger.ONE); ptu.setPower(BigInteger.valueOf(new Random().nextInt(9999))); ptu.setPrice(new BigDecimal(BigInteger.valueOf(new Random().nextInt(9999)), 2)); ptu.setDisposition(DispositionAvailableRequested.REQUESTED); return ptu;/*from w w w .j a v a 2 s . co m*/ }