Пример #1
0
  /**
   * Converts a primitive type value, this implementation only converts an EEnum to an Enum value.
   *
   * @param value the value to convert
   * @param eDataType its EDataType
   * @return the converted value
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected Object convertEAttributeValue(final Object value, final EDataType eDataType) {
    if (value instanceof Enum<?>) {
      final EDataType enumDataType = getDataTypeOrBaseType(eDataType);
      Check.isInstanceOf(enumDataType, EEnum.class);
      final ModelPackage modelPackage =
          ModelResolver.getInstance().getModelPackage(enumDataType.getEPackage().getNsURI());
      final Class<? extends Enum> enumClass =
          (Class<? extends Enum>) modelPackage.getEClassifierClass(enumDataType);
      return Enum.valueOf(enumClass, ((Enum<?>) value).name().toUpperCase(Locale.ENGLISH));
    } else if (value instanceof EEnumLiteral) {
      final EDataType enumDataType = getDataTypeOrBaseType(eDataType);
      Check.isInstanceOf(enumDataType, EEnum.class);
      final EEnumLiteral eeNumLiteral = (EEnumLiteral) value;
      final ModelPackage modelPackage =
          ModelResolver.getInstance().getModelPackage(enumDataType.getEPackage().getNsURI());
      if (modelPackage == null) {
        // dynamic model
        return eeNumLiteral;
      }
      final Class<? extends Enum> enumClass =
          (Class<? extends Enum>) modelPackage.getEClassifierClass(enumDataType);
      return Enum.valueOf(enumClass, eeNumLiteral.getName().toUpperCase(Locale.ENGLISH));
    }

    // convert these to a Date always
    if (value instanceof XMLGregorianCalendar) {
      final XMLGregorianCalendar xmlCalendar = (XMLGregorianCalendar) value;
      final Date date = xmlCalendar.toGregorianCalendar().getTime();
      return date;
    }

    return value;
  }
  @Override
  public String getAsString(FacesContext context, UIComponent component, Object value) {
    Map<String, Object> attributes = component.getAttributes();

    if (attributes.containsKey("pattern")) {
      pattern = (String) attributes.get("pattern");
    }
    setPattern(pattern);

    if (attributes.containsKey("locale")) {
      locale = (Locale) attributes.get("locale");
    }
    setLocale(locale);

    if (attributes.containsKey("timeZone")) {
      timeZone = (TimeZone) attributes.get("timeZone");
    }
    setTimeZone(timeZone);
    if (attributes.containsKey("dateStyle")) {
      dateStyle = (String) attributes.get("dateStyle");
    }
    setDateStyle(dateStyle);
    if (attributes.containsKey("timeStyle")) {
      timeStyle = (String) attributes.get("timeStyle");
    }
    setTimeStyle(timeStyle);
    if (attributes.containsKey("type")) {
      type = (String) attributes.get("type");
    }
    setType(type);

    XMLGregorianCalendar xmlGregCal = (XMLGregorianCalendar) value;
    Date date = xmlGregCal.toGregorianCalendar().getTime();
    return super.getAsString(context, component, date);
  }
Пример #3
0
  public void performIteration(Object port) throws Exception {
    XMLGregorianCalendar ret = ((EndpointWrappedRPC) port).getCalendarPlusDay(testedCalendar);

    if (!ret.equals(expectedCalendar)) {
      throw new Exception("Unexpected result: " + ret + "\nExpected:" + expectedCalendar);
    }
  }
  /**
   * Add an new empty feed::dasextension element with only a completed management element to the
   * given Feed. Sets the responseTime value to now. Note: A proper sites::site element must be
   * added to the new feed::dasextension element for this new feed::dasextension element to be
   * valid.
   *
   * @param feed - mandatory
   * @return
   */
  private Feed addEmptyDasExtension(Feed feed) {

    // check to make sure there's a dasextension
    QName dasextensionQname = new QName(this.dasextensionNamespace, "dasextension");
    ExtensibleElement dasExt = feed.getExtension(dasextensionQname);
    if (NullChecker.isEmpty(dasExt)) {

      dasExt = feed.addExtension(dasextensionQname);

      // add the dasextension::management element
      QName managementQname = new QName(this.dasextensionNamespace, "management");
      ExtensibleElement management = dasExt.getExtension(managementQname);
      if (NullChecker.isEmpty(management)) {
        management = dasExt.addExtension(managementQname);
      }

      QName responseTimeQname = new QName(this.dasextensionNamespace, "responseTime");
      ExtensibleElement responseTime = management.getExtension(responseTimeQname);
      if (NullChecker.isEmpty(responseTime)) {
        responseTime = management.addExtension(responseTimeQname);
      }

      // set/reset the response time to now
      XMLGregorianCalendar xmlGregCalResponseTime =
          GregorianDateUtil.getGregorianCalendarByDate(new Date());
      responseTime.setText(xmlGregCalResponseTime.toString()); // TODO: Verify date format
    }
    return feed;
  }
    private Element createUsernameToken(String usernameValue, String passwordValue)
        throws SOAPException {

      QName usernameTokenName =
          new QName(Constants.WSSE_NS, Constants.WSSE_USERNAME_TOKEN, Constants.WSSE_PREFIX);
      QName usernameName =
          new QName(Constants.WSSE_NS, Constants.WSSE_USERNAME, Constants.WSSE_PREFIX);
      QName passwordName =
          new QName(Constants.WSSE_NS, Constants.WSSE_PASSWORD, Constants.WSSE_PREFIX);
      QName createdName = new QName(Constants.WSU_NS, "Created", Constants.WSU_PREFIX);

      SOAPFactory factory = SOAPFactory.newInstance();
      SOAPElement usernametoken = factory.createElement(usernameTokenName);
      usernametoken.addNamespaceDeclaration(Constants.WSSE_PREFIX, Constants.WSSE_NS);
      usernametoken.addNamespaceDeclaration(Constants.WSU_PREFIX, Constants.WSU_NS);
      SOAPElement username = factory.createElement(usernameName);
      username.addTextNode(usernameValue);
      SOAPElement password = factory.createElement(passwordName);
      password.addAttribute(new QName("Type"), Constants.PASSWORD_TEXT_TYPE);
      password.addTextNode(passwordValue);

      SOAPElement created = factory.createElement(createdName);
      XMLGregorianCalendar createdCal =
          dataTypefactory.newXMLGregorianCalendar(new GregorianCalendar()).normalize();
      created.addTextNode(createdCal.toXMLFormat());

      usernametoken.addChildElement(username);
      usernametoken.addChildElement(password);
      usernametoken.addChildElement(created);
      return usernametoken;
    }
Пример #6
0
 public static GregorianCalendar toGregorianCalendar(String date) {
   try {
     XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(date);
     return xmlDate.toGregorianCalendar();
   } catch (DatatypeConfigurationException dtce) {
     throw new UnsupportedOperationException(
         "Nemohu prevest " + "GregorianCalendar na XMLGregorianCalendar", dtce);
   }
 }
 private String createResetEmail(OrcidProfile orcidProfile, String baseUri) {
   String userEmail =
       orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue();
   XMLGregorianCalendar date =
       DateUtils.convertToXMLGregorianCalendarNoTimeZoneNoMillis(new Date());
   String resetParams =
       MessageFormat.format(
           "email={0}&issueDate={1}", new Object[] {userEmail, date.toXMLFormat()});
   return createEmailBaseUrl(resetParams, baseUri, "reset-password-email");
 }
Пример #8
0
 public Date getTimeStamp() {
   if (flow == null) return null;
   AdministrativeInformation info = flow.getAdministrativeInformation();
   if (info == null) return null;
   DataEntry entry = info.getDataEntry();
   if (entry == null) return null;
   XMLGregorianCalendar cal = entry.getTimeStamp();
   if (cal == null) return null;
   else return cal.toGregorianCalendar().getTime();
 }
  @Test
  public void testToXmlDate() throws Exception {
    Calendar cal = Calendar.getInstance();
    cal.set(2014, Calendar.DECEMBER, 15, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);

    XMLGregorianCalendar actual = DocumentUtils.toXmlDate(cal.getTime());

    assertEquals("2014-12-15", actual.toXMLFormat());
  }
 static {
   try {
     GregorianCalendar calendar = new GregorianCalendar();
     calendar.setTimeInMillis((new Date()).getTime());
     XMLGregorianCalendar xmlGregCal =
         DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
     FEED = FEED_STR.replace("@TIME@", xmlGregCal.toXMLFormat());
   } catch (DatatypeConfigurationException e) {
     throw new RuntimeException(e);
   }
 }
Пример #11
0
  /**
   * Load the data in parallel using a provided number of threads.
   *
   * @param threads The number of threads to use.
   * @param start The start range for the generated data.
   * @param end The end range for the generated data.
   * @param dataInterval The interval in between sensor data.
   */
  public static void parallelLoad(
      int threads, XMLGregorianCalendar start, XMLGregorianCalendar end, final int dataInterval) {
    // Partition time period into separate threads.
    List<ClientThread> clients = new ArrayList<ClientThread>();
    final long begin = start.toGregorianCalendar().getTimeInMillis();
    final long interval = (end.toGregorianCalendar().getTimeInMillis() - begin) / threads;
    final double totalEnergyGenerated[] = {
      0, 1234.0, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012
    };

    for (int i = 0; i < threads; i++) {
      clients.add(
          new ClientThread(i) {
            @Override
            public void run() {
              SensorData data;
              int j = 0;
              Properties props;
              int power = 0;

              XMLGregorianCalendar timestamp = Tstamp.makeTimestamp(begin + (interval * threadId));
              XMLGregorianCalendar myEnd =
                  Tstamp.makeTimestamp(begin + (interval * (threadId + 1)));
              while (Tstamp.lessThan(timestamp, myEnd)) {
                for (int k = 0; k < NUM_SOURCES; k++) {
                  props = new Properties();
                  power = j * (k + 1) * 100;
                  // energy counter increased by power * rate, converted to Wh
                  totalEnergyGenerated[k] += power * dataInterval / 60.0;
                  props
                      .getProperty()
                      .add(new Property(SensorData.POWER_GENERATED, Integer.toString(power)));
                  props
                      .getProperty()
                      .add(
                          new Property(
                              SensorData.ENERGY_GENERATED_TO_DATE,
                              Double.toString(totalEnergyGenerated[k])));
                  data = new SensorData(timestamp, toolName, sourceURIs[k], props);
                  try {
                    client.storeSensorData(data);
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }
                timestamp = Tstamp.incrementMilliseconds(timestamp, dataInterval * 1000);
                // Keep ratcheting up j until we reach 100, then reset to 0
                j = (j < 100) ? j + 10 : 0;
              }
            }
          });
    }
  }
  public Object toJavaObject(Class target) throws XPathException {
    if (target == Object.class || target.isAssignableFrom(DateValue.class)) return this;
    else if (target.isAssignableFrom(XMLGregorianCalendar.class)) return calendar.clone();
    else if (target.isAssignableFrom(GregorianCalendar.class))
      return calendar.toGregorianCalendar();
    else if (target == Date.class) return calendar.toGregorianCalendar().getTime();

    throw new XPathException(
        "cannot convert value of type "
            + Type.getTypeName(getType())
            + " to Java object of type "
            + target.getName());
  }
Пример #13
0
  /**
   * Add additional time in miliseconds
   *
   * @param value calendar whose value needs to be updated
   * @param milis
   * @return calendar value with the addition
   * @throws ConfigurationException
   */
  public static XMLGregorianCalendar add(XMLGregorianCalendar value, long milis)
      throws ConfigurationException {
    XMLGregorianCalendar newVal = (XMLGregorianCalendar) value.clone();

    Duration duration;
    try {
      duration = newDatatypeFactory().newDuration(milis);
    } catch (DatatypeConfigurationException e) {
      throw logger.configurationError(e);
    }
    newVal.add(duration);
    return newVal;
  }
Пример #14
0
  /**
   * Validate that the current time falls between the two boundaries
   *
   * @param now
   * @param notbefore
   * @param notOnOrAfter
   * @return
   */
  public static boolean isValid(
      XMLGregorianCalendar now, XMLGregorianCalendar notbefore, XMLGregorianCalendar notOnOrAfter) {
    if (notbefore == null) throw logger.nullArgumentError("notbefore argument is null");
    if (notOnOrAfter == null) throw logger.nullArgumentError("notOnOrAfter argument is null");

    int val = notbefore.compare(now);

    if (val == DatatypeConstants.INDETERMINATE || val == DatatypeConstants.GREATER) return false;

    val = notOnOrAfter.compare(now);
    if (val != DatatypeConstants.GREATER) return false;
    return true;
  }
  @Override
  public String marshal(Date date) throws Exception {
    if (date == null) {
      return null;
    }

    long utcMillis = date.getTime();
    GregorianCalendar calendar = new GregorianCalendar(TimeZone.getDefault());
    calendar.setTimeInMillis(utcMillis);

    DatatypeFactory factory = DatatypeFactory.newInstance();
    XMLGregorianCalendar xmlCalendar = factory.newXMLGregorianCalendar(calendar);
    return xmlCalendar.toXMLFormat();
  }
 /**
  * Return a calendar with the timezone field set, to be used for order comparison. If the original
  * calendar did not specify a timezone, set the local timezone (unadjusted for daylight savings).
  * The returned calendars will be totally ordered between themselves. We also set any missing
  * fields to ensure that normalization doesn't discard important data! (This is probably a bug in
  * the JAXP implementation, but the workaround doesn't hurt us, so it's faster to just fix it
  * here.)
  *
  * @return the calendar represented by this object, with the timezone field filled in with an
  *     implicit value if necessary
  */
 protected XMLGregorianCalendar getImplicitCalendar() {
   if (implicitCalendar == null) {
     implicitCalendar = (XMLGregorianCalendar) calendar.clone();
     if (calendar.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
       implicitCalendar.setTimezone(TimeUtils.getInstance().getLocalTimezoneOffsetMinutes());
     }
     // fill in fields from default reference; don't have to worry about weird combinations of
     // fields being set, since we control that on creation
     switch (getType()) {
       case Type.DATE:
         implicitCalendar.setTime(0, 0, 0);
         break;
       case Type.TIME:
         implicitCalendar.setYear(1972);
         implicitCalendar.setMonth(12);
         implicitCalendar.setDay(31);
         break;
       default:
     }
     implicitCalendar =
         implicitCalendar
             .normalize(); // the comparison routines will normalize it anyway, just do it once
                           // here
   }
   return implicitCalendar;
 }
Пример #17
0
  private boolean validateAssertionAge(
      AssertionType assertion, Map<String, String> runtimeProperties) {
    long nowInMillis = new GregorianCalendar().getTimeInMillis();

    XMLGregorianCalendar issued = assertion.getIssueInstant();
    long issuedInMillis = issued.toGregorianCalendar().getTimeInMillis();

    long maxAgeInMillis =
        Long.parseLong(getProperty(VALIDATOR_AGE_MAXAGESECONDS, runtimeProperties)) * 1000;
    if (nowInMillis - issuedInMillis <= maxAgeInMillis) {
      return true;
    }
    return false;
  }
  static String format(Date date) {
    XMLGregorianCalendar xgCal = null;
    if (date != null) {
      GregorianCalendar gCal = new GregorianCalendar();
      gCal.setTime(date);
      try {
        xgCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCal);
      } catch (DatatypeConfigurationException e) {
        return "";
      }
    }

    return (xgCal == null) ? "" : xgCal.toXMLFormat();
  }
Пример #19
0
 @Mapping(from = Integer.class, to = XMLGregorianCalendar.class)
 public static synchronized XMLGregorianCalendar map(
     BigDecimal secondsAgo, XMLGregorianCalendar template) {
   GregorianCalendar calendar =
       template != null
           ? template.toGregorianCalendar()
           : new GregorianCalendar(TimeZone.getTimeZone("UTC"));
   DatatypeFactory factory = getDatatypeFactory();
   XMLGregorianCalendar ret = null;
   if (factory != null) {
     ret = factory.newXMLGregorianCalendar(calendar);
     ret.add(factory.newDuration(false, 0, 0, 0, 0, 0, secondsAgo.intValue()));
   }
   return ret;
 }
Пример #20
0
 private String dateToString(Date date) {
   String result = null;
   if (date != null) {
     try {
       GregorianCalendar cal = new GregorianCalendar();
       cal.setTime(date);
       XMLGregorianCalendar xmlCal;
       DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
       xmlCal = datatypeFactory.newXMLGregorianCalendar(cal);
       result = xmlCal.toString();
     } catch (DatatypeConfigurationException e) {
       // nothing to do
     }
   }
   return result;
 }
Пример #21
0
  public static Date toDate(XMLGregorianCalendar cal) {
    if (null != cal) {
      return cal.toGregorianCalendar().getTime();
    }

    return null;
  }
 protected XMLGregorianCalendar getTrimmedCalendar() {
   if (trimmedCalendar == null) {
     trimmedCalendar = cloneXMLGregorianCalendar(calendar);
     BigDecimal fract = trimmedCalendar.getFractionalSecond();
     if (fract != null) {
       // TODO: replace following algorithm in JDK 1.5 with fract.stripTrailingZeros();
       String s = fract.toString();
       int i = s.length();
       while (i > 0 && s.charAt(i - 1) == '0') i--;
       if (i == 0) trimmedCalendar.setFractionalSecond(null);
       else if (i != s.length())
         trimmedCalendar.setFractionalSecond(new BigDecimal(s.substring(0, i)));
     }
   }
   return trimmedCalendar;
 }
Пример #23
0
 /**
  * check if the specified XMLGregorianCalendar instance is a valid {@odf.datatype time} data type
  *
  * @param time the value to be tested
  * @return true if the value of argument is valid for {@odf.datatype time} data type false
  *     otherwise
  */
 public static boolean isValid(XMLGregorianCalendar time) {
   if (time == null) {
     return false;
   } else {
     return W3CSchemaType.isValid("time", time.toXMLFormat());
   }
 }
Пример #24
0
 /**
  * Class-level synchronization to avoid potential thread-safety issues with statically shared
  * DatatypeFactory.
  */
 @Mapping(from = Date.class, to = XMLGregorianCalendar.class)
 public static synchronized XMLGregorianCalendar map(Date date, XMLGregorianCalendar template) {
   GregorianCalendar calendar =
       template != null ? template.toGregorianCalendar() : new GregorianCalendar();
   calendar.setTime(date);
   DatatypeFactory factory = getDatatypeFactory();
   return factory != null ? factory.newXMLGregorianCalendar(calendar) : null;
 }
Пример #25
0
 public static String date2GregorianCalendarString(Date date) {
   if (date == null) {
     throw new java.lang.IllegalArgumentException("Date is null");
   }
   long tmp = date.getTime();
   GregorianCalendar ca = new GregorianCalendar();
   ca.setTimeInMillis(tmp);
   try {
     XMLGregorianCalendar t_XMLGregorianCalendar =
         DatatypeFactory.newInstance().newXMLGregorianCalendar(ca);
     return t_XMLGregorianCalendar.normalize().toString();
   } catch (DatatypeConfigurationException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     throw new java.lang.IllegalArgumentException("Date is null");
   }
 }
  @Override
  public Date unmarshal(String rawValue) throws Exception {
    if (!StringUtility.hasText(rawValue)) {
      return null;
    }

    // local time of given timezone (or default timezone if not applicable)
    DatatypeFactory factory = DatatypeFactory.newInstance();
    XMLGregorianCalendar xmlCalendar = factory.newXMLGregorianCalendar(rawValue);
    GregorianCalendar calendar = xmlCalendar.toGregorianCalendar();
    long utcMillis = calendar.getTimeInMillis();

    // default time
    Calendar defaultTimezoneCalendar = Calendar.getInstance();
    defaultTimezoneCalendar.setTimeInMillis(utcMillis);
    return defaultTimezoneCalendar.getTime();
  }
 protected XMLGregorianCalendar validateTerminationTime(String value)
     throws UnacceptableTerminationTimeFault {
   XMLGregorianCalendar tt = parseTerminationTime(value);
   if (tt == null) {
     UnacceptableTerminationTimeFaultType fault = new UnacceptableTerminationTimeFaultType();
     throw new UnacceptableTerminationTimeFault(
         "Unable to parse termination time: '" + value + "'", fault);
   }
   XMLGregorianCalendar ct = getCurrentTime();
   int c = tt.compare(ct);
   if (c == DatatypeConstants.LESSER || c == DatatypeConstants.EQUAL) {
     UnacceptableTerminationTimeFaultType fault = new UnacceptableTerminationTimeFaultType();
     fault.setMinimumTime(ct);
     throw new UnacceptableTerminationTimeFault("Invalid termination time", fault);
   }
   return tt;
 }
Пример #28
0
  @POST
  @Consumes("application/xml")
  @Path("storeXML")
  public Response storeXML(DataCollectionPackage dataCollectionPackage) {
    String sourceID = dataCollectionPackage.getSourceID();
    String eventID = dataCollectionPackage.getEventID();

    if (dataCollectionPackage.getDataRecords() == null
        || dataCollectionPackage.getDataRecords().getDataCollectionRecord() == null) {
      ResponseBuilder builder = Response.status(Status.INTERNAL_SERVER_ERROR);
      builder.type("text/html");
      builder.entity("<h3>No records included</h3>");
      throw new WebApplicationException(builder.build());
    }

    for (DataCollectionRecord dr :
        dataCollectionPackage.getDataRecords().getDataCollectionRecord()) {

      // JAXB datatype for dateTime is XMLGregorianCalendar, need to convert to the
      // java.sql.Timestamp
      XMLGregorianCalendar cal = dr.getTimestamp();
      GregorianCalendar gregorianCalendar = cal.toGregorianCalendar();
      long timeAsMillis = gregorianCalendar.getTimeInMillis();
      Timestamp timestamp = new Timestamp(timeAsMillis);

      // persist data here
    }

    URI createdURI = null;
    try {
      // Create a relative URI
      createdURI = new URI("records");
    } catch (URISyntaxException e) {
      throw new WebApplicationException(Response.serverError().build());
    }
    // For a successful POST send a 201 CREATED with the URI of where to find the records
    // The relative URI will be turned into an absolute URI based on the URI used to access
    // this method.
    // return Response.created(createdURI).build();
    ResponseBuilder builder = Response.created(createdURI);
    builder.type("text/plain");
    // SoapUI considers a 0 length response an error
    builder.entity("storeXML");
    return builder.build();
  }
  /**
   * @param actividadxx
   * @return
   * @throws DatatypeConfigurationException
   */
  public String sombreadoc(Actividad actividadxx) throws DatatypeConfigurationException {
    if (actividadxx != null) {
      WrActividad actividadx = consultarActividad(actividadxx);
      if (actividadx.getActividads().get(0).getFechaCierre() != null
          && actividadx.getActividads().get(0).getFechaApertura() != null) {
        XMLGregorianCalendar FC1;
        XMLGregorianCalendar FA1;
        FC1 = actividadx.getActividads().get(0).getFechaCierre();
        FA1 = actividadx.getActividads().get(0).getFechaApertura();
        long duracion = actividadx.getActividads().get(0).getDuracion().longValue();
        equivalencia = actividadx.getActividads().get(0).getIdEquivalenciasTiempo().getNombre();
        UT = actividadx.getActividads().get(0).getIdEquivalenciasTiempo().getMinutos();
        long f = FC1.toGregorianCalendar().getTimeInMillis();
        long f2 = FA1.toGregorianCalendar().getTimeInMillis();
        long resta = f - f2;

        if ("Minuto".equals(equivalencia)) {
          long minutos = resta / (60 * 1000);
          if (minutos > duracion) {
            return "background-color:  #FF8888;";
          }
        }
        if ("Hora".equals(equivalencia)) {
          long horas = resta / (60 * 60 * 1000);
          if (horas > duracion) {
            return "background-color:  #FF8888;";
          }
        }
        if ("Dia".equals(equivalencia)) {
          long dias = resta / (24 * 60 * 60 * 1000);
          if (dias > duracion) {
            return "background-color:  #FF8888;";
          }
        }
        if ("Semana".equals(equivalencia)) {
          long semanas = resta / (7 * 24 * 60 * 60 * 1000);
          if (semanas > duracion) {
            return "background-color:  #FF8888;";
          }
        }
      }
      return " background-color: white";
    }
    return " background-color: white;";
  }
 private String toStringValue(Object value) {
   if (null == value) return null;
   Date date = null;
   if (value instanceof XMLGregorianCalendar) {
     XMLGregorianCalendar grCal = (XMLGregorianCalendar) value;
     Calendar calendar = Calendar.getInstance();
     calendar.set(Calendar.DAY_OF_MONTH, grCal.getDay());
     calendar.set(Calendar.MONTH, grCal.getMonth() - 1);
     calendar.set(Calendar.YEAR, grCal.getYear());
     date = calendar.getTime();
   } else if (value instanceof Date) {
     date = (Date) value;
   }
   if (null != date) {
     return DateConverter.getFormattedDate(date, DATE_PATTERN);
   }
   return null;
 }