public static XProperties xPropertiesFromMap(Map<String, String> map) { ObjectFactory xCF = new ObjectFactory(); if (map != null && !map.isEmpty()) { XProperties xp = xCF.createXProperties(); List<XProperty> xpList = xp.getProperty(); for (Map.Entry<String, String> e : map.entrySet()) { XProperty property = xCF.createXProperty(); property.setName(e.getKey()); property.setValue(e.getValue()); xpList.add(property); } return xp; } return null; }
/** * Get the dimension specified by name * * @param sessionid The sessionid in which user is working * @param dimName The dimension name * @return JAXB representation of {@link XDimension} */ @GET @Path("/dimensions/{dimName}") public JAXBElement<XDimension> getDimension(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("dimName") String dimName) throws LensException { checkSessionId(sessionid); return X_CUBE_OBJECT_FACTORY.createXDimension(getSvc().getDimension(sessionid, dimName)); }
public APIResult createDimensionTable(XDimensionTable table) { WebTarget target = getMetastoreWebTarget(); return translate(target.path("dimtables") .queryParam("sessionid", this.connection.getSessionHandle()) .request(MediaType.APPLICATION_XML) .post(Entity.xml(new GenericEntity<JAXBElement<XDimensionTable>>(objFact.createXDimensionTable(table)){}))); }
public static XProperties getXpropertiesFromSegment(Segment cseg) { XProperties xproperties = XCF.createXProperties(); for (String prop : cseg.getProperties().keySet()) { String segPrefix = MetastoreUtil.getSegmentPropertyKey(cseg.getName()); if (prop.startsWith(segPrefix)){ XProperty xprop = XCF.createXProperty(); xprop.setName(prop.replace(segPrefix, "")); xprop.setValue(cseg.getProperties().get(prop)); xproperties.getProperty().add(xprop); } } return xproperties; }
final XCube cube = createTestCube("testCube"); target().path("metastore").path("cubes").queryParam("sessionid", lensSessionId).request(mediaType) .post(Entity.entity(new GenericEntity<JAXBElement<XCube>>(cubeObjectFactory.createXCube(cube)) { }, mediaType), APIResult.class); XFactTable f = createFactTable(table); APIResult result = target().path("metastore").path("facts").queryParam("sessionid", lensSessionId) .request(mediaType) .post(Entity.entity(new GenericEntity<JAXBElement<XFact>>(cubeObjectFactory.createXFact(f)) { }, mediaType), APIResult.class); assertSuccess(result); .put(Entity.entity(new GenericEntity<JAXBElement<XFact>>(cubeObjectFactory.createXFact(update)) { }, mediaType), APIResult.class); assertSuccess(result); APIResult partAddResult = target().path("metastore/facts/").path(table).path("storages/S1/partition") .queryParam("sessionid", lensSessionId).request(mediaType) .post(Entity.entity(new GenericEntity<JAXBElement<XPartition>>(cubeObjectFactory.createXPartition(xp)) { }, mediaType), APIResult.class); assertSuccess(partAddResult); .post(Entity.entity(new GenericEntity<JAXBElement<XPartition>>(cubeObjectFactory.createXPartition(xp)) { }, mediaType), APIResult.class); assertEquals(partAddResult.getStatus(), Status.FAILED); APIResult partUpdateResult = target().path("metastore/facts/").path(table).path("storages/S1/partition") .queryParam("sessionid", lensSessionId).request(mediaType) .put(Entity.entity(new GenericEntity<JAXBElement<XPartition>>(cubeObjectFactory.createXPartition(xp)) {
XProperty prop = cubeObjectFactory.createXProperty(); prop.setName("dim.prop2.name"); prop.setValue("dim.prop2.value"); XDimAttribute xd1 = cubeObjectFactory.createXDimAttribute(); xd1.setName("col3Added"); xd1.setType("STRING"); .queryParam("sessionid", lensSessionId) .request(mediaType).put(Entity.entity(new GenericEntity<JAXBElement<XDimension>>(cubeObjectFactory .createXDimension(testDim)){}, mediaType), APIResult.class); assertSuccess(result);
XBaseCube cube = cubeObjectFactory.createXBaseCube(); cube.setName(cubeName); cube.setDimAttributes(new XDimAttributes()); cube.setJoinChains(new XJoinChains()); cube.setProperties(new XProperties()); XDimAttribute xd1 = cubeObjectFactory.createXDimAttribute(); xd1.setName("dim1"); xd1.setType("STRING"); XDimAttribute xd2 = cubeObjectFactory.createXDimAttribute(); xd2.setName("dim2"); xd2.setType("INT"); XDimAttribute xd3 = cubeObjectFactory.createXDimAttribute(); xd3.setName("testdim2col2"); xd3.setType("STRING"); XDimAttribute xd4 = cubeObjectFactory.createXDimAttribute(); xd4.setName("dim4"); xd4.setType("struct<a:INT,b:array<string>,c:map<int,array<struct<x:int,y:array<int>>>"); xj1.setDisplayString("Chain-1"); xj1.setPaths(new XJoinPaths()); XJoinPath path1 = cubeObjectFactory.createXJoinPath(); path1.setEdges(new XJoinEdges()); XTableReference link1 = new XTableReference(); link2.setColumn("col1");
/** * Get the storage specified by name * * @param sessionid The sessionid in which user is working * @param storageName The storage name * @return JAXB representation of {@link XStorage} */ @GET @Path("/storages/{storage}") public JAXBElement<XStorage> getStorage(@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("storage") String storageName) throws LensException { checkSessionId(sessionid); return X_CUBE_OBJECT_FACTORY.createXStorage(getSvc().getStorage(sessionid, storageName)); }
public APIResult createSegmentation(XSegmentation seg) { WebTarget target = getMetastoreWebTarget(); return translate(target.path("segmentations") .queryParam("sessionid", this.connection.getSessionHandle()) .request(MediaType.APPLICATION_XML) .post(Entity.xml(new GenericEntity<JAXBElement<XSegmentation>>(objFact .createXSegmentation(seg)){}))); }
XDimAttribute xd3 = cubeObjectFactory.createXDimAttribute(); xd3.setName("col3"); xd3.setType("STRING"); XDimAttribute xd4 = cubeObjectFactory.createXDimAttribute(); xd4.setName("col4"); xd4.setDescription("hierarchical column"); xd4.setDisplayString("Column4"); XDimAttributes hierarchy = new XDimAttributes(); XDimAttribute hd1 = cubeObjectFactory.createXDimAttribute(); hd1.setName("col4-h1"); hd1.setType("STRING"); hd1.getValues().add("Val3-h1"); hierarchy.getDimAttribute().add(hd1); XDimAttribute hd2 = cubeObjectFactory.createXDimAttribute(); hd2.setName("col4-h2"); hd2.setType("STRING"); hd2.setDisplayString("Column4-h2"); hierarchy.getDimAttribute().add(hd2); XDimAttribute hd3 = cubeObjectFactory.createXDimAttribute(); hd3.setName("col4-h3"); hd3.setType("STRING"); XDimAttribute xd5 = cubeObjectFactory.createXDimAttribute(); xd5.setName("col5"); xd5.setType("INT");
public APIResult createCube(XCube cube) { WebTarget target = getMetastoreWebTarget(); return translate(target.path("cubes") .queryParam("sessionid", this.connection.getSessionHandle()) .request(MediaType.APPLICATION_XML) .post(Entity.xml(new GenericEntity<JAXBElement<XCube>>(objFact.createXCube(cube)){}))); }
public APIResult createFactTable(XFact f) { WebTarget target = getMetastoreWebTarget(); return translate(target.path("facts") .queryParam("sessionid", this.connection.getSessionHandle()) .request(MediaType.APPLICATION_XML) .post(Entity.xml(new GenericEntity<JAXBElement<XFact>>(objFact.createXFact(f)){}))); }
private void createStorage(String storageName, MediaType mediaType) throws Exception { WebTarget target = target().path("metastore").path("storages"); XStorage xs = new XStorage(); xs.setProperties(new XProperties()); xs.setName(storageName); xs.setClassname(HDFSStorage.class.getCanonicalName()); XProperty prop = cubeObjectFactory.createXProperty(); prop.setName("prop1.name"); prop.setValue("prop1.value"); xs.getProperties().getProperty().add(prop); APIResult result = target.queryParam("sessionid", lensSessionId).request(mediaType).post( Entity.entity(new GenericEntity<JAXBElement<XStorage>>(cubeObjectFactory.createXStorage(xs)) { }, mediaType), APIResult.class); assertNotNull(result); assertSuccess(result); }
private XStorageTableDesc createStorageTableDesc(String name, final String[] timePartColNames) { XStorageTableDesc xs1 = cubeObjectFactory.createXStorageTableDesc(); XProperties props = cubeObjectFactory.createXProperties(); XProperty propStartTime = cubeObjectFactory.createXProperty(); propStartTime.setName(MetastoreUtil.getStoragetableStartTimesKey()); propStartTime.setValue("now -10 days"); XProperty propEndTime = cubeObjectFactory.createXProperty(); propEndTime.setName(MetastoreUtil.getStoragetableEndTimesKey()); propEndTime.setValue("now +5 days"); XColumn partCol = cubeObjectFactory.createXColumn(); partCol.setName(timePartColName); partCol.setType("STRING");
private XSegmentation createSegmentation(String segName, String cubeName) { XSegmentation seg = cubeObjectFactory.createXSegmentation(); XProperties props1 = cubeObjectFactory.createXProperties(); XProperty prop1 = new XProperty(); prop1.setName("prop_key1"); props1.getProperty().add(prop1); XProperties props2 = cubeObjectFactory.createXProperties(); XProperty prop2 = new XProperty(); prop2.setName("prop_key2"); XSegment c1 = cubeObjectFactory.createXSegment(); c1.setCubeName("cube1"); c1.setSegmentParameters(props1); XSegment c2 = cubeObjectFactory.createXSegment(); c2.setCubeName("cube2"); c2.setSegmentParameters(props2);
private XDimensionTable createDimTable(String dimName, String table) { XDimensionTable dt = cubeObjectFactory.createXDimensionTable(); dt.setDimensionName(dimName); dt.setTableName(table); dt.setWeight(15.0); dt.setColumns(new XColumns()); dt.setProperties(new XProperties()); dt.setStorageTables(new XStorageTables()); XColumn c1 = cubeObjectFactory.createXColumn(); c1.setName("col1"); c1.setType("STRING"); c1.setComment("Fisrt column"); dt.getColumns().getColumn().add(c1); XColumn c2 = cubeObjectFactory.createXColumn(); c2.setName("col2"); c2.setType("INT"); c2.setComment("Second column"); dt.getColumns().getColumn().add(c2); XProperty p1 = cubeObjectFactory.createXProperty(); p1.setName("foodim"); p1.setValue("bardim"); dt.getProperties().getProperty().add(p1); return dt; }
public APIResult addPartitionsToDimensionTable(String dimTblName, String storage, XPartitionList partitions) { WebTarget target = getMetastoreWebTarget(); return translate(target.path("dimtables").path(dimTblName) .path("storages").path(storage).path("partitions") .queryParam("sessionid", this.connection.getSessionHandle()) .request(MediaType.APPLICATION_XML) .post(Entity.xml(new GenericEntity<JAXBElement<XPartitionList>>(objFact.createXPartitionList(partitions)){}))); }
private XDimensionTable createDimTable(String dimTableName, MediaType mediaType) throws Exception { XDimension dimension = createDimension("testdim"); APIResult result = target().path("metastore").path("dimensions") .queryParam("sessionid", lensSessionId).request( mediaType).post(Entity.entity(new GenericEntity<JAXBElement<XDimension>>(cubeObjectFactory .createXDimension(dimension)) {}, mediaType), APIResult.class); assertSuccess(result); XDimensionTable dt = createDimTable("testdim", dimTableName); dt.getStorageTables().getStorageTable().add(createStorageTblElement("test", dimTableName, "HOURLY")); result = target() .path("metastore") .path("dimtables").queryParam("sessionid", lensSessionId) .request(mediaType) .post(Entity.entity( new GenericEntity<JAXBElement<XDimensionTable>>(cubeObjectFactory.createXDimensionTable(dt)) {}, mediaType), APIResult.class); assertSuccess(result); return dt; }
public LensMetadataClient(LensConnection connection) { this.connection = connection; this.params = connection.getLensConnectionParams(); objFact = new ObjectFactory(); }
.request(mediaType) .post(Entity.entity( new GenericEntity<JAXBElement<XFact>>(cubeObjectFactory.createXFact(f)){}, mediaType), APIResult.class); assertSuccess(result); .queryParam("sessionid", lensSessionId).request(mediaType) .post(Entity.entity(new GenericEntity<JAXBElement<XStorageTableElement>>(cubeObjectFactory .createXStorageTableElement(sTbl)){}, mediaType), APIResult.class); assertSuccess(result);