@Test public void testUpdate() { MetaClass m1 = createMetaClass(); m1.setName("update"); IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); ms.createMetaClass(m1, new MetadataContext()); MetaClass m2 = createMetaClass(); m2.setName("update"); m2.setpluralName("updates"); ms.updateMetaClass(m2, metaContext); MetaAttribute attribute = new MetaAttribute(); attribute.setName("classOfService"); attribute.setDataType(MetaField.DataTypeEnum.INTEGER); }
@Test public void testInherit_updateMetaClassSetParentToNull() { IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); MetaClass mp51 = createMetaClass(); mp51.setName("mp51"); MetaClass mp52 = createMetaClass(); mp52.setName("mp52"); mp52.setParent("mp51"); ms.batchUpsert(Arrays.asList(mp51, mp52), metaContext); mp52 = createMetaClass(); mp52.setName("mp52"); MetaAttribute a = new MetaAttribute(); a.setName("ax"); mp52.setParent(""); ms.updateMetaClass(mp52, metaContext); MetaClass getChild = ms.getMetaClass("mp52"); Assert.assertEquals("", getChild.getParent()); }
@Test (expected=MetaFieldExistsException.class) public void testInherit_appendFieldToChildConflict() { IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); MetaClass mp21 = createMetaClass(); mp21.setName("mp21"); MetaAttribute a1 = new MetaAttribute(); a1.setName("a1"); mp21.addField(a1); MetaClass mp22 = createMetaClass(); mp22.setName("mp22"); mp22.setParent("mp21"); ms.batchUpsert(Arrays.asList(mp21, mp22), metaContext); mp22 = createMetaClass(); mp22.setName("mp22"); mp22.setParent("mp21"); MetaAttribute a11 = new MetaAttribute(); a11.setName("a1"); mp22.addField(a11); ms.updateMetaClass(mp22, metaContext); }
mp91.setName("mp91"); mp91.setAllowFullTableScan(false); ms.updateMetaClass(mp91, metaContext); mp92.setName("mp92"); mp92.setParent(""); ms.updateMetaClass(mp92, metaContext);
@Test public void testInherit_updateParent() { IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); MetaClass mp61 = createMetaClass(); mp61.setName("mp61"); MetaClass mp62 = createMetaClass(); mp62.setName("mp62"); MetaClass mp63 = createMetaClass(); mp63.setName("mp63"); mp63.setParent("mp61"); ms.batchUpsert(Arrays.asList(mp61, mp62, mp63), metaContext); mp63 = createMetaClass(); mp63.setName("mp63"); mp63.setParent("mp62"); mp63.setDescription("new description updated"); mp63.setAllowFullTableScan(true); ms.updateMetaClass(mp63, metaContext); MetaClass getMC = ms.getMetaClass(mp63.getName()); Assert.assertEquals("mp62", getMC.getParent()); Assert.assertEquals(true, getMC.isAllowFullTableScan()); Assert.assertEquals("new description updated", getMC.getDescription()); List<String> ancestors = getMC.getAncestors(); Assert.assertTrue(ancestors.contains(mp62.getName())); Assert.assertTrue(!ancestors.contains(mp61.getName())); }
@Test (expected=MetaFieldExistsException.class) public void testInherit_appendFieldToParentConflict() { IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); MetaClass mp31 = createMetaClass(); mp31.setName("mp31"); MetaAttribute a1 = new MetaAttribute(); a1.setName("a1"); mp31.addField(a1); MetaClass mp32 = createMetaClass(); mp32.setName("mp32"); MetaAttribute a2 = new MetaAttribute(); a2.setName("a2"); mp32.addField(a2); mp32.setParent("mp31"); ms.batchUpsert(Arrays.asList(mp31, mp32), metaContext); mp31 = createMetaClass(); mp31.setName("mp31"); MetaAttribute a11 = new MetaAttribute(); a11.setName("a2"); mp31.addField(a11); ms.updateMetaClass(mp31, metaContext); }
newMetaClass.addIndex(index2); metaService.updateMetaClass(newMetaClass, metaContext); getMeta = metaService.getMetaClass(newMetaClass.getName()); indexes = getMeta.getIndexesOnField(attribute1.getName());
public void testUpdate_duplicateSameField() { MetaClass m1 = createMetaClass(); m1.setName("update1"); MetaAttribute a = new MetaAttribute(); a.setName("classOfService"); a.setDataType(MetaField.DataTypeEnum.INTEGER); m1.addField(a); IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); ms.createMetaClass(m1, new MetadataContext()); MetaClass m2 = createMetaClass(); m2.setName("update1"); MetaAttribute a1 = new MetaAttribute(); a1.setName("classOfService"); a1.setDataType(MetaField.DataTypeEnum.INTEGER); m2.addField(a1); ms.updateMetaClass(m2, metaContext); }
@Test public void testUpdateMetaAddIndex() { MetaClass metaClass = createMetaClass(); metaClass.setName("metaUpdateAddIndex"); MetaAttribute attribute = new MetaAttribute(); attribute.setName("attr_Name1"); attribute.setDataType(DataTypeEnum.STRING); metaClass.addField(attribute); IndexInfo index = new IndexInfo("indexName1"); index.getKeyList().add(attribute.getName()); metaClass.addIndex(index); IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); metaService.createMetaClass(metaClass, new MetadataContext()); MetaClass getMeta = metaService.getMetaClass(metaClass.getName()); Assert.assertEquals(3, getMeta.getIndexes().size()); MetaClass metaClass2 = createMetaClass(); metaClass2.setName(metaClass.getName()); attribute.setDbName(null); attribute.setValueDbName(null); attribute.setFlattenValueDbName(null); metaClass2.addField(attribute); IndexInfo addIndex = new IndexInfo("indexName2"); addIndex.addKeyField(attribute.getName()); metaClass2.addIndex(addIndex); metaService.updateMetaClass(metaClass2, metaContext); getMeta = metaService.getMetaClass(metaClass.getName()); Assert.assertEquals(4, getMeta.getIndexes().size()); }
@Test(expected=MetaFieldExistsException.class) public void testUpdate_duplicateDiffField() { MetaClass m1 = createMetaClass(); m1.setName("update2"); MetaAttribute a = new MetaAttribute(); a.setName("classOfService"); a.setDataType(MetaField.DataTypeEnum.INTEGER); m1.addField(a); IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); ms.createMetaClass(m1, new MetadataContext()); MetaClass m2 = createMetaClass(); m2.setName("update2"); MetaAttribute a1 = new MetaAttribute(); a1.setName("classOfService"); a1.setDataType(MetaField.DataTypeEnum.BOOLEAN); m2.addField(a1); ms.updateMetaClass(m2, metaContext); }
@Test public void testInherit_updateParent2() { IMetadataService ms = repositoryService.getRepository(repoName).getMetadataService(); MetaClass mp61 = createMetaClass(); mp61.setName("mp61"); MetaClass mp62 = createMetaClass(); mp62.setName("mp62"); mp62.setParent("mp61"); MetaClass mp63 = createMetaClass(); mp63.setName("mp63"); mp63.setParent("mp62"); ms.batchUpsert(Arrays.asList(mp61, mp62, mp63), metaContext); MetaClass updateMC = createMetaClass(); updateMC.setName("mp61"); updateMC.setParent("mp63"); updateMC.setDescription("new description updated"); try { ms.updateMetaClass(updateMC, metaContext); Assert.fail(); } catch (IllegalMetaClassException e) { //expected } //assert not changed MetaClass getMC = ms.getMetaClass(updateMC.getName()); Assert.assertEquals(null, getMC.getParent()); Assert.assertEquals(null, getMC.getDescription()); }
metaService.updateMetaClass(embedMeta, metaContext);
metaService.updateMetaClass(innerMeta, metaContext);
metaService.updateMetaClass(innerMeta3, metaContext); metaService.updateMetaClass(innerMeta3, metaContext);
a2.setName("a2"); mp1.addField(a2); ms.updateMetaClass(mp1, metaContext);
metaService.updateMetaClass(row, metaContext);
mp81.setDescription("new description updated"); mp81.setAllowFullTableScan(true); ms.updateMetaClass(mp81, metaContext); metaAttr.setName("mp81-attr1"); mp81.addField(metaAttr); ms.updateMetaClass(mp81, metaContext); metaAttr2.setDataType(DataTypeEnum.LONG); mp81.addField(metaAttr2); ms.updateMetaClass(mp81, metaContext);