@Test public void testDealWithMappingForCubeDesc() throws IOException { CubeDescManager cubeDescManager = CubeDescManager.getInstance(getTestConfig()); CubeDesc cubeDesc = cubeDescManager.getCubeDesc("ci_left_join_cube"); CubeDesc updated = TableSchemaUpdater.dealWithMappingForCubeDesc(cubeDesc, mappings); updated = reinit(updated, cubeDescManager.CUBE_DESC_SERIALIZER); try (DataInputStream bis = new DataInputStream( new FileInputStream(new File(mappingRootPath + CubeDesc.concatResourcePath(updated.getName()))))) { CubeDesc expected = cubeDescManager.CUBE_DESC_SERIALIZER.deserialize(bis); Assert.assertTrue(expected.equalsRaw(updated)); } catch (Exception e) { Assert.fail("CubeDesc is not updated correctly"); } }
public static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings) { CubeDesc copy = CubeDesc.getCopyOf(other); copy.setLastModified(other.getLastModified()); if (other.getSnapshotTableDescList() != null && !other.getSnapshotTableDescList().isEmpty()) { List<SnapshotTableDesc> snapshotTableDescListCopy = Lists .newArrayListWithExpectedSize(other.getSnapshotTableDescList().size()); for (SnapshotTableDesc snapshotDesc : other.getSnapshotTableDescList()) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, snapshotDesc.getTableName()); if (mapping != null && mapping.isTableIdentityChanged()) { snapshotDesc = SnapshotTableDesc.getCopyOf(snapshotDesc); snapshotDesc.setTableName(mapping.getTableIdentity(snapshotDesc.getTableName())); } snapshotTableDescListCopy.add(snapshotDesc); } copy.setSnapshotTableDescList(snapshotTableDescListCopy); } return copy; }
TableSchemaUpdater { public static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings) { CubeDesc copy = CubeDesc.getCopyOf(other); copy.setLastModified(other.getLastModified()); if (other.getSnapshotTableDescList() != null && !other.getSnapshotTableDescList().isEmpty()) { List<SnapshotTableDesc> snapshotTableDescListCopy = Lists .newArrayListWithExpectedSize(other.getSnapshotTableDescList().size()); for (SnapshotTableDesc snapshotDesc : other.getSnapshotTableDescList()) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, snapshotDesc.getTableName()); if (mapping != null && mapping.isTableIdentityChanged()) { snapshotDesc = SnapshotTableDesc.getCopyOf(snapshotDesc); snapshotDesc.setTableName(mapping.getTableIdentity(snapshotDesc.getTableName())); } snapshotTableDescListCopy.add(snapshotDesc); } copy.setSnapshotTableDescList(snapshotTableDescListCopy); } return copy; } }
TableSchemaUpdater { public static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings) { CubeDesc copy = CubeDesc.getCopyOf(other); copy.setLastModified(other.getLastModified()); if (other.getSnapshotTableDescList() != null && !other.getSnapshotTableDescList().isEmpty()) { List<SnapshotTableDesc> snapshotTableDescListCopy = Lists .newArrayListWithExpectedSize(other.getSnapshotTableDescList().size()); for (SnapshotTableDesc snapshotDesc : other.getSnapshotTableDescList()) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, snapshotDesc.getTableName()); if (mapping != null && mapping.isTableIdentityChanged()) { snapshotDesc = SnapshotTableDesc.getCopyOf(snapshotDesc); snapshotDesc.setTableName(mapping.getTableIdentity(snapshotDesc.getTableName())); } snapshotTableDescListCopy.add(snapshotDesc); } copy.setSnapshotTableDescList(snapshotTableDescListCopy); } return copy; }  }
TableSchemaUpdater { public static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings) { CubeDesc copy = CubeDesc.getCopyOf(other); copy.setLastModified(other.getLastModified()); if (other.getSnapshotTableDescList() != null && !other.getSnapshotTableDescList().isEmpty()) { List<SnapshotTableDesc> snapshotTableDescListCopy = Lists .newArrayListWithExpectedSize(other.getSnapshotTableDescList().size()); for (SnapshotTableDesc snapshotDesc : other.getSnapshotTableDescList()) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, snapshotDesc.getTableName()); if (mapping != null && mapping.isTableIdentityChanged()) { snapshotDesc = SnapshotTableDesc.getCopyOf(snapshotDesc); snapshotDesc.setTableName(mapping.getTableIdentity(snapshotDesc.getTableName())); } snapshotTableDescListCopy.add(snapshotDesc); } copy.setSnapshotTableDescList(snapshotTableDescListCopy); } return copy; }  static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings); static DataModelDesc dealWithMappingForModel(DataModelDesc other,
            Map<String, TableSchemaUpdateMapping> mappings); static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings); static CubeInstance dealWithMappingForCube(CubeInstance other,
            Map<String, TableSchemaUpdateMapping> mappings); static TableSchemaUpdateMapping getTableSchemaUpdateMapping(Map<String, TableSchemaUpdateMapping> mappings,
            String key); }
TableSchemaUpdater { public static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings) { CubeDesc copy = CubeDesc.getCopyOf(other); copy.setLastModified(other.getLastModified()); if (other.getSnapshotTableDescList() != null && !other.getSnapshotTableDescList().isEmpty()) { List<SnapshotTableDesc> snapshotTableDescListCopy = Lists .newArrayListWithExpectedSize(other.getSnapshotTableDescList().size()); for (SnapshotTableDesc snapshotDesc : other.getSnapshotTableDescList()) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, snapshotDesc.getTableName()); if (mapping != null && mapping.isTableIdentityChanged()) { snapshotDesc = SnapshotTableDesc.getCopyOf(snapshotDesc); snapshotDesc.setTableName(mapping.getTableIdentity(snapshotDesc.getTableName())); } snapshotTableDescListCopy.add(snapshotDesc); } copy.setSnapshotTableDescList(snapshotTableDescListCopy); } return copy; }  static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings); static DataModelDesc dealWithMappingForModel(DataModelDesc other,
            Map<String, TableSchemaUpdateMapping> mappings); static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings); static CubeInstance dealWithMappingForCube(CubeInstance other,
            Map<String, TableSchemaUpdateMapping> mappings); static TableSchemaUpdateMapping getTableSchemaUpdateMapping(Map<String, TableSchemaUpdateMapping> mappings,
            String key);  }