List of usage examples for java.util GregorianCalendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * //set subscription, make a change as the same user, get subscription * results. valid. publisher assertion, incomplete * * @throws DatatypeConfigurationException *//*from ww w . j a va 2s . com*/ @Test public void JUDDI_606_15() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_15"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelSam.saveSamSyndicatorTmodel(authInfoSam); tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam); Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport()); sub.getSubscriptionFilter().getGetAssertionStatusReport() .setCompletionStatus(CompletionStatus.STATUS_TO_KEY_INCOMPLETE); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); AddPublisherAssertions r = new AddPublisherAssertions(); r.setAuthInfo(authInfoJoe); PublisherAssertion pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem()); Assert.assertFalse(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().isEmpty()); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getFromKey(), TckBusiness.JOE_BUSINESS_KEY); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getToKey(), TckBusiness.SAM_BUSINESS_KEY); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus()); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus(), CompletionStatus.STATUS_TO_KEY_INCOMPLETE); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getKeyedReference()); } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam); tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results valid publisher assertion, deleted * * @throws DatatypeConfigurationException *//*ww w. j a v a2 s .c o m*/ @Test public void JUDDI_606_17() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_17"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelSam.saveSamSyndicatorTmodel(authInfoSam); tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam); Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport()); sub.getSubscriptionFilter().getGetAssertionStatusReport() .setCompletionStatus(CompletionStatus.STATUS_BOTH_INCOMPLETE); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); AddPublisherAssertions r = new AddPublisherAssertions(); r.setAuthInfo(authInfoJoe); PublisherAssertion pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); //approve it r = new AddPublisherAssertions(); r.setAuthInfo(authInfoSam); r.getPublisherAssertion().add(pa); publicationSam.addPublisherAssertions(r); DeletePublisherAssertions dp = new DeletePublisherAssertions(); dp.setAuthInfo(authInfoJoe); dp.getPublisherAssertion().add(pa); publicationJoe.deletePublisherAssertions(dp); dp = new DeletePublisherAssertions(); dp.setAuthInfo(authInfoSam); dp.getPublisherAssertion().add(pa); //publicationSam.deletePublisherAssertions(dp); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem()); Assert.assertTrue(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().isEmpty()); /* Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getFromKey(), TckBusiness.JOE_BUSINESS_KEY); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getToKey(), TckBusiness.SAM_BUSINESS_KEY); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getCompletionStatus()); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getCompletionStatus(), CompletionStatus.STATUS_BOTH_INCOMPLETE); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getKeyedReference());*/ } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam); tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam); } }
From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java
/** * set subscription, make a change as the same user, get subscription * results valid publisher assertion, complete * * @throws DatatypeConfigurationException *//*w w w . j ava 2 s . c o m*/ @Test public void JUDDI_606_16() throws DatatypeConfigurationException { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JUDDI_606_16"); Assume.assumeTrue(TckPublisher.isSubscriptionEnabled()); DatatypeFactory df = DatatypeFactory.newInstance(); try { tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelSam.saveSamSyndicatorTmodel(authInfoSam); tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam); Holder<List<Subscription>> data = new Holder<List<Subscription>>(); data.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBrief(false); sub.setExpiresAfter(null); sub.setMaxEntities(null); sub.setNotificationInterval(null); sub.setBindingKey(null); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport()); sub.getSubscriptionFilter().getGetAssertionStatusReport() .setCompletionStatus(CompletionStatus.STATUS_COMPLETE); data.value.add(sub); tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data); AddPublisherAssertions r = new AddPublisherAssertions(); r.setAuthInfo(authInfoJoe); PublisherAssertion pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); r = new AddPublisherAssertions(); r.setAuthInfo(authInfoSam); pa = new PublisherAssertion(); pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY); pa.setToKey(TckBusiness.SAM_BUSINESS_KEY); pa.setKeyedReference(new KeyedReference()); pa.getKeyedReference().setKeyName("Subsidiary"); pa.getKeyedReference().setKeyValue("parent-child"); pa.getKeyedReference().setTModelKey("uddi:uddi.org:relationships"); r.getPublisherAssertion().add(pa); publicationJoe.addPublisherAssertions(r); GetSubscriptionResults gsr = new GetSubscriptionResults(); gsr.setAuthInfo(authInfoJoe); gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey()); gsr.setCoveragePeriod(new CoveragePeriod()); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, -1); gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal)); SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription .getSubscriptionResults(gsr); Assert.assertNotNull(subscriptionResults); Assert.assertNull(subscriptionResults.getBusinessList()); Assert.assertNotNull(subscriptionResults.getCoveragePeriod()); Assert.assertNull(subscriptionResults.getServiceList()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport()); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem()); Assert.assertFalse(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().isEmpty()); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getFromKey(), TckBusiness.JOE_BUSINESS_KEY); Assert.assertEquals( subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0).getToKey(), TckBusiness.SAM_BUSINESS_KEY); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus()); Assert.assertEquals(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getCompletionStatus(), CompletionStatus.STATUS_COMPLETE); Assert.assertNotNull(subscriptionResults.getAssertionStatusReport().getAssertionStatusItem().get(0) .getKeyedReference()); } catch (Exception ex) { HandleException(ex); Assert.fail(ex.getMessage()); } finally { tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam); tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam); } }
From source file:org.eevolution.form.VCRP.java
public CategoryDataset createDataset(Timestamp start, MResource r) { //System.out.println("Create new data set"); GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);/*from w ww . java 2 s . c o m*/ gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); System.out.println("\n Namecapacity :" + namecapacity); String nameload = Msg.translate(Env.getCtx(), "Load"); System.out.println("\n Nameload :" + nameload); String namesummary = Msg.translate(Env.getCtx(), "Summary"); System.out.println("\n Namesummary :" + namesummary); MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); System.out.println("\n Resourcetype " + t); int days = 1; long hours = 0; if (t.isTimeSlot()) { hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd()); } else { //fjviejo e-evolution MachineQty if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0) hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue(); else //fjviejo e-evolution end hours = 24; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", r.getS_Resource_ID()); MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null); System.out.println("\n uom1 " + uom + "\n"); //System.out.println("um.isHour()"+ uom.isHour() ); if (!uom.isHour()) { System.out.println("\n uom2 " + uom + "\n"); return dataset; } System.out.println("\n Dataset " + dataset + "\n"); int summary = 0; //int cont = 1; DateFormat formatter = DateFormat.getDateInstance(); /* * Vit4B Modificado para que tome 28 dias y * * */ while (days < 29) { /* * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * * //System.out.println("Day Number" + days); String strday = formatter.format(date); //String day = new String(new Integer (date.getDate()).toString()); String day = new String(formatter.format(date)); //day = day.substring(0,5); int index = day.indexOf("/"); String str = day.substring(0,index); System.out.println("str: " + str + " index de / " + index); String str2 = day.substring(index+1,day.length()); System.out.println("str2 resto: " + str2); index = str2.indexOf("/"); System.out.println(index); String str3 = str2.substring(0,index); System.out.println("str3: " + str3 + " index de / " + index); String str4 = str2.substring(index+1,str2.length()); System.out.println(str4); System.out.println("dia: " + str); System.out.println("mes: " + str3); System.out.println("ao: " + str4); //day = str + str3; day = new String(str + str3); //day = day.substring(0,day.lastIndexOf("/")); //day =day.substring(0,3); //cont++; System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date: " + date + " day: " + day); int seconds = getLoad(r.getS_Resource_ID(),date ,date); Long Hours = new Long(hours); System.out.println("Summary "+ summary); System.out.println("Capacity "+ hours); System.out.println("Load "+ seconds); /* * * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * */ /* * ORIGINAL COMPIERE */ String day = new String(new Integer(date.getDate()).toString()); System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date:" + date); /* * VIT4B - Modificacin para calcular como se calcula el reporte CCRP * en funcion de la carga parcial * * */ int seconds = getLoad(r.getS_Resource_ID(), date, date); //BigDecimal value = calculateLoad(date, r, null); //int seconds = value.intValue(); Long Hours = new Long(hours); System.out.println("Summary " + summary); System.out.println("Load " + seconds); /* * FIN ORIGINAL COMPIERE * */ switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { //System.out.println("si Sunday"); //Msg.translate(Env.getCtx(), "OnSunday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600))); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Sunday"); //String day = Msg.translate(Env.getCtx(), "OnSunday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { //System.out.println("si Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { //System.out.println("si TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } } } return dataset; }
From source file:org.apache.juddi.api.impl.UDDISubscriptionImpl.java
/** * Will add the expiration date to the provided subscription request. Date is earlier of user provided date and the system default * //from www . j a v a2 s . co m * @param apiSubscription * @throws DispositionReportFaultMessage */ private void doSubscriptionExpirationDate(org.uddi.sub_v3.Subscription apiSubscription) throws DispositionReportFaultMessage { int subscriptionExpirationDays = DEFAULT_SUBSCRIPTIONEXPIRATION_DAYS; try { subscriptionExpirationDays = AppConfig.getConfiguration() .getInt(Property.JUDDI_SUBSCRIPTION_EXPIRATION_DAYS); } catch (ConfigurationException ce) { throw new FatalErrorException(new ErrorMessage("errors.configuration.Retrieval")); } GregorianCalendar expirationDate = new GregorianCalendar(); expirationDate.add(GregorianCalendar.DAY_OF_MONTH, subscriptionExpirationDays); // The expiration date is the earlier of the provided date and that specified by the parameter. if (apiSubscription.getExpiresAfter() != null) { GregorianCalendar userExpiration = apiSubscription.getExpiresAfter().toGregorianCalendar(); if (userExpiration.getTimeInMillis() < expirationDate.getTimeInMillis()) expirationDate.setTimeInMillis(userExpiration.getTimeInMillis()); } try { DatatypeFactory df = DatatypeFactory.newInstance(); apiSubscription.setExpiresAfter(df.newXMLGregorianCalendar(expirationDate)); } catch (DatatypeConfigurationException ce) { throw new FatalErrorException(new ErrorMessage("errors.Unspecified")); } }
From source file:hudson.model.Job.java
private Calendar getLastBuildTime() { final RunT lastBuild = getLastBuild(); if (lastBuild == null) { final GregorianCalendar neverBuiltCalendar = new GregorianCalendar(); neverBuiltCalendar.setTimeInMillis(0); return neverBuiltCalendar; }/*from w w w . j av a2 s . c om*/ return lastBuild.getTimestamp(); }
From source file:pl.psnc.synat.wrdz.common.metadata.mets.MetsMetadataBuilder.java
/** * Sets an object creation date.//w w w .j a va 2 s . com * * @param date * object creation date * @return this builder */ public MetsMetadataBuilder setCreationDate(Date date) { MetsHdr header = getHeaderSection(); GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(date.getTime()); header.setCREATEDATE(datatypeFactory.newXMLGregorianCalendar(gc)); return this; }
From source file:pl.psnc.synat.wrdz.common.metadata.mets.MetsMetadataBuilder.java
/** * Sets an object modification date.//from w w w. j a v a2 s . c om * * @param date * object modification date * @return this builder */ public MetsMetadataBuilder setModificationDate(Date date) { MetsHdr header = getHeaderSection(); GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(date.getTime()); header.setLASTMODDATE(datatypeFactory.newXMLGregorianCalendar(gc)); return this; }
From source file:org.sakaiproject.calendar.impl.RecurrenceRuleBase.java
/** * Return a List of all RecurrenceInstance objects generated by this rule within the given time range, based on the * prototype first range, in time order.//from ww w . ja va 2s. c o m * @param prototype The prototype first TimeRange. * @param range A time range to limit the generated ranges. * @param timeZone The time zone to use for displaying times. * %%% Note: this is currently not implemented, and always uses the "local" zone. * @return a List of RecurrenceInstance generated by this rule in this range. */ public List generateInstances(TimeRange prototype, TimeRange range, TimeZone timeZone) { // these calendars are used if local time zone and the time zone where the first event was created (timeZone) are different GregorianCalendar firstEventCalendarDate = null; GregorianCalendar nextFirstEventCalendarDate = null; // %%% Note: base the breakdonw on the "timeZone" parameter to support multiple timeZone displays -ggolden TimeBreakdown startBreakdown = prototype.firstTime().breakdownLocal(); GregorianCalendar startCalendarDate = TimeService.getCalendar(TimeService.getLocalTimeZone(), 0, 0, 0, 0, 0, 0, 0); startCalendarDate.set(startBreakdown.getYear(), startBreakdown.getMonth() - 1, startBreakdown.getDay(), startBreakdown.getHour(), startBreakdown.getMin(), startBreakdown.getSec()); // if local time zone and first event time zone are different // a new calendar is generated to calculate the re-occurring events // if not, the local time zone calendar is used boolean differentTimeZone = false; if (TimeService.getLocalTimeZone().getID().equals(timeZone.getID())) { differentTimeZone = false; } else { differentTimeZone = true; } if (differentTimeZone) { firstEventCalendarDate = TimeService.getCalendar(timeZone, 0, 0, 0, 0, 0, 0, 0); firstEventCalendarDate.setTimeInMillis(startCalendarDate.getTimeInMillis()); nextFirstEventCalendarDate = (GregorianCalendar) firstEventCalendarDate.clone(); } List rv = new Vector(); GregorianCalendar nextCalendarDate = (GregorianCalendar) startCalendarDate.clone(); int currentCount = 1; do { if (differentTimeZone) { // next time is calculated according to the first event time zone, not the local one nextCalendarDate.setTimeInMillis(nextFirstEventCalendarDate.getTimeInMillis()); } Time nextTime = TimeService.newTime(nextCalendarDate); // is this past count? if ((getCount() > 0) && (currentCount > getCount())) break; // is this past until? if ((getUntil() != null) && isAfter(nextTime, getUntil())) break; TimeRange nextTimeRange = TimeService.newTimeRange(nextTime.getTime(), prototype.duration()); // // Is this out of the range? // if (isOverlap(range, nextTimeRange)) { TimeRange eventTimeRange = null; // Single time cases require special handling. if (prototype.isSingleTime()) { eventTimeRange = TimeService.newTimeRange(nextTimeRange.firstTime()); } else { eventTimeRange = TimeService.newTimeRange(nextTimeRange.firstTime(), nextTimeRange.lastTime(), true, false); } // use this one rv.add(new RecurrenceInstance(eventTimeRange, currentCount)); } // if next starts after the range, stop generating else if (isAfter(nextTime, range.lastTime())) break; // advance interval years. if (differentTimeZone) { nextFirstEventCalendarDate = (GregorianCalendar) firstEventCalendarDate.clone(); nextFirstEventCalendarDate.add(getRecurrenceType(), getInterval() * currentCount); } else { nextCalendarDate = (GregorianCalendar) startCalendarDate.clone(); nextCalendarDate.add(getRecurrenceType(), getInterval() * currentCount); } currentCount++; } while (true); return rv; }
From source file:org.apache.juddi.v3.tck.UDDI_141_JIRAIntegrationTest.java
/** * testing upper case subscription callbacks * * @throws Exception/*w w w .j a v a 2s. com*/ */ @Test public void JIRA_597() throws Exception { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JIRA_597"); int port = 7000; String hostname = TckPublisher.getProperties().getProperty("bindaddress"); if (hostname == null) { hostname = InetAddress.getLocalHost().getHostName(); } TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe); UDDISubscriptionListenerImpl.notifcationMap.clear(); UDDISubscriptionListenerImpl.notificationCount = 0; Endpoint ep = null; boolean ok = false; do { try { logger.info("Attempting to bring up endpoint at " + "http://" + hostname + ":" + port + "/UDDI_CALLBACK"); ep = Endpoint.publish("http://" + hostname + ":" + port + "/UDDI_CALLBACK", impl); ok = true; } catch (Exception ex) { logger.warn("Trouble starting endpoint: " + ex.getMessage()); port++; } } while (!ok); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(authInfoJoe); BusinessEntity be = new BusinessEntity(); be.getName().add(new Name()); be.getName().get(0).setValue("Joe's callback business"); be.setBusinessServices(new BusinessServices()); BusinessService bs = new BusinessService(); bs.getName().add(new Name()); bs.getName().get(0).setValue("Joe's callback service"); bs.setBindingTemplates(new BindingTemplates()); BindingTemplate bt = new BindingTemplate(); bt.setAccessPoint(new AccessPoint()); bt.getAccessPoint().setValue("http://" + hostname + ":" + port + "/UDDI_CALLBACK"); bt.getAccessPoint().setUseType("endPoint"); //Added per Kurt TModelInstanceInfo instanceInfo = new TModelInstanceInfo(); instanceInfo.setTModelKey("uddi:uddi.org:transport:http"); bt.setTModelInstanceDetails(new TModelInstanceDetails()); bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo); bs.getBindingTemplates().getBindingTemplate().add(bt); bs.getBindingTemplates().getBindingTemplate().add(bt); be.getBusinessServices().getBusinessService().add(bs); sb.getBusinessEntity().add(be); BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb); List<String> deleteme = new ArrayList<String>(); deleteme.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); //ok Joe's callback is setup //Setup a business to subscribe to sb = new SaveBusiness(); sb.setAuthInfo(authInfoSam); be = new BusinessEntity(); be.getName().add(new Name()); be.getName().get(0).setValue("Sam's business"); sb.getBusinessEntity().add(be); BusinessDetail saveBusiness1 = publicationSam.saveBusiness(sb); //ok Joe now needs to subscribe for Sam's business Holder<List<Subscription>> list = new Holder<List<Subscription>>(); list.value = new ArrayList<Subscription>(); Subscription s = new Subscription(); s.setBindingKey(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0) .getBindingTemplates().getBindingTemplate().get(0).getBindingKey()); s.setSubscriptionFilter(new SubscriptionFilter()); s.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail()); s.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey() .add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey()); DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, 1); s.setExpiresAfter(df.newXMLGregorianCalendar(gcal)); s.setNotificationInterval(df.newDuration(5000)); list.value.add(s); subscriptionJoe.saveSubscription(authInfoJoe, list); //ok have sam change his business around. sb = new SaveBusiness(); sb.setAuthInfo(authInfoSam); be = saveBusiness1.getBusinessEntity().get(0); be.getName().get(0).setLang("en"); sb.getBusinessEntity().add(be); publicationSam.saveBusiness(sb); int maxwait = 30000; logger.info("waiting for callbacks"); while (maxwait > 0) { if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) { break; } Thread.sleep(1000); maxwait = maxwait - 1000; } TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe); this.DeleteBusinesses(deleteme, authInfoJoe, publicationJoe); deleteme.clear(); deleteme.add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey()); this.DeleteBusinesses(deleteme, authInfoSam, publicationSam); ep.stop(); if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) { Assert.fail("no callbacks were recieved."); } }