@Override public String toString() { return toString(this); } }
public static <T> T fromXMLString(String xml, Class<? extends T> clazz) { return ToXMLString.valueOf(xml, clazz); } }
public static <T> T valueOf(String sessionStr, Class tClass) { try { Unmarshaller unmarshaller = getLensJAXBContext(tClass).createUnmarshaller(); Object ret = unmarshaller.unmarshal(new StringReader(sessionStr)); if (ret instanceof JAXBElement) { return ((JAXBElement<T>) ret).getValue(); } return (T) ret; } catch (JAXBException e) { return null; } }
@Override public String toString() { return toString(this); } }
public static <T> T fromXMLString(String xml, Class<? extends T> clazz) { return ToXMLString.valueOf(xml, clazz); } }
public static <T> T valueOf(String sessionStr, Class tClass) { try { Unmarshaller unmarshaller = getLensJAXBContext(tClass).createUnmarshaller(); Object ret = unmarshaller.unmarshal(new StringReader(sessionStr)); if (ret instanceof JAXBElement) { return ((JAXBElement<T>) ret).getValue(); } return (T) ret; } catch (JAXBException e) { return null; } }
public String toXMLString() { return ToXMLString.toString(this); }
/** * Gets the job definition * * @param id * @return Xjob corresponding to the job handle * @throws SQLException */ public XJob getJob(String id) throws SQLException { String fetchSQL = "SELECT " + COLUMN_JOB + " FROM " + JOB_TABLE + " WHERE " + COLUMN_ID + "=?"; List<Object[]> result = runner.query(fetchSQL, multipleRowsHandler, id); if (result.size() == 0) { return null; } else { return ToXMLString.valueOf((String) result.get(0)[0], ObjectFactory.class); } }
public static String toString(Object o) { if (!(o instanceof JAXBElement) && o.getClass().getAnnotation(XmlRootElement.class) == null && o.getClass().getAnnotation(XmlType.class)!= null) { o = new JAXBElement(new QName("uri:lens:cube:0.1", o.getClass().getAnnotation(XmlType.class).name()), o.getClass(), null, o); } try { StringWriter stringWriter = new StringWriter(); Class cl = null; if (o instanceof JAXBElement) { cl = ((JAXBElement) o).getDeclaredType(); } else { cl = o.getClass(); } Marshaller marshaller = getLensJAXBContext(cl).createMarshaller(); marshaller.marshal(o, stringWriter); return stringWriter.toString(); } catch (JAXBException e) { throw new RuntimeException(e); } }
public String toXMLString() { return ToXMLString.toString(this); }
/** * Gets the Job info object * * @param idStr * @return SchedulerJobInfo object corresponding to the job handle. * @throws SQLException */ public SchedulerJobInfo getSchedulerJobInfo(String idStr) throws SQLException { String fetchSQL = "SELECT * FROM " + JOB_TABLE + " WHERE " + COLUMN_ID + "=?"; List<Object[]> result = runner.query(fetchSQL, multipleRowsHandler, idStr); if (result.size() == 0) { return null; } else { Object[] jobInfo = result.get(0); SchedulerJobHandle id = SchedulerJobHandle.fromString((String) jobInfo[0]); XJob xJob = ToXMLString.valueOf((String) jobInfo[1], ObjectFactory.class); String userName = (String) jobInfo[2]; String status = (String) jobInfo[3]; long createdOn = (Long) jobInfo[4]; long modifiedOn = (Long) jobInfo[5]; SchedulerJobState jobState = SchedulerJobState.valueOf(status); return new SchedulerJobInfo(id, xJob, userName, jobState, createdOn, modifiedOn); } }
public static String toString(Object o) { if (!(o instanceof JAXBElement) && o.getClass().getAnnotation(XmlRootElement.class) == null && o.getClass().getAnnotation(XmlType.class)!= null) { o = new JAXBElement(new QName("uri:lens:cube:0.1", o.getClass().getAnnotation(XmlType.class).name()), o.getClass(), null, o); } try { StringWriter stringWriter = new StringWriter(); Class cl = null; if (o instanceof JAXBElement) { cl = ((JAXBElement) o).getDeclaredType(); } else { cl = o.getClass(); } Marshaller marshaller = getLensJAXBContext(cl).createMarshaller(); marshaller.marshal(o, stringWriter); return stringWriter.toString(); } catch (JAXBException e) { throw new RuntimeException(e); } }
/** * Update the XJob into the job table * * @param id * @param job * @param modifiedOn * @return the number of rows updated * @throws SQLException */ public int updateJob(String id, XJob job, long modifiedOn) throws SQLException { String updateSQL = "UPDATE " + JOB_TABLE + " SET " + COLUMN_JOB + "=?, " + COLUMN_MODIFIED_ON + "=? " + " WHERE " + COLUMN_ID + "=?"; JAXBElement<XJob> xmlJob = jobFactory.createJob(job); return runner.update(updateSQL, ToXMLString.toString(xmlJob), modifiedOn, id); }
private void write() throws IOException { for (Object object : getNewObjectsForYAML()) { BufferedWriter xmlWriter = new BufferedWriter(new FileWriter(new File("src/test/resources/toString/" + object.getClass().getName() + ".xml"))); BufferedWriter toStringWriter = new BufferedWriter(new FileWriter(new File("src/test/resources/toString/" + object.getClass().getName() + ".yaml"))); xmlWriter.write(XML_LICENSE_HEADER); xmlWriter.write(ToXMLString.toString(object)); xmlWriter.close(); toStringWriter.write(YAML_HEADER); toStringWriter.write(object.toString()); toStringWriter.close(); } }
public LensAPIResult updateJob(XJob job, String jobHandle, String sessionHandleString) throws JAXBException, IOException, ParseException, DatatypeConfigurationException { MapBuilder map = new MapBuilder("sessionid", sessionHandleString); JAXBElement<XJob> xmlJob = new ObjectFactory().createJob(job); Response response = this.exec("put", SCHEDULER_JOBS_URL + "/" + jobHandle, servLens, null, map, MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_XML, ToXMLString.toString(xmlJob)); AssertUtil.assertSucceededResponse(response); return response.readEntity(LensAPIResult.class); }
try(BufferedWriter bw = new BufferedWriter(new FileWriter(getClass() .getResource("/schema/facts").getPath()+"/"+cubeFactTable.getName()+".xml"))) { bw.write(ToXMLString.toString(client.getXFactTable(cubeFactTable))); try(BufferedWriter bw = new BufferedWriter(new FileWriter(getClass() .getResource("/schema/dimtables").getPath()+"/"+dim.getName()+".xml"))) { bw.write(ToXMLString.toString(client.getXDimensionTable(dim)));
/** * Inserts the Job info object into job table * * @param jobInfo * @return number of rows inserted. * @throws SQLException */ public int insertIntoJobTable(SchedulerJobInfo jobInfo) throws SQLException { String insertSQL = "INSERT INTO " + JOB_TABLE + " VALUES(?,?,?,?,?,?,?)"; JAXBElement<XJob> xmlJob = jobFactory.createJob(jobInfo.getJob()); return runner.update(insertSQL, jobInfo.getId().toString(), ToXMLString.toString(xmlJob), jobInfo.getUserName(), jobInfo.getJobState().name(), jobInfo.getCreatedOn(), jobInfo.getModifiedOn(), jobInfo.getJob().getName()); }