@Test public void testUpdate() { final ItemDefinition item1 = makeItemDefinition("model1.tPerson", null, true); final ItemDefinition item2 = makeItemDefinition("model1.id", "number", true); final ItemDefinition item3 = makeItemDefinition("model1.name", "string", true); final ItemDefinition item4 = makeItemDefinition("person", "model1.tPerson", false); final List<ItemDefinition> itemDefinitions = asList(item1, item2, item3, item4); doNothing().when(handler).notifyPropertiesPanel(anyString(), anyString()); when(itemDefinitionUtils.all()).thenReturn(itemDefinitions); handler.update("model1", "model2"); verify(refreshDataTypesListEvent).fire(any(RefreshDataTypesListEvent.class)); assertEquals("model2.tPerson", item1.getName().getValue()); assertNull(item1.getTypeRef()); verify(handler).notifyPropertiesPanel("model1.tPerson", "model2.tPerson"); assertEquals("model2.id", item2.getName().getValue()); assertEquals("number", item2.getTypeRef().getLocalPart()); verify(handler).notifyPropertiesPanel("model1.id", "model2.id"); assertEquals("model2.name", item3.getName().getValue()); assertEquals("string", item3.getTypeRef().getLocalPart()); verify(handler).notifyPropertiesPanel("model1.name", "model2.name"); assertEquals("person", item4.getName().getValue()); assertEquals("model2.tPerson", item4.getTypeRef().getLocalPart()); }
@Override public void update(final String oldModelName, final String newModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); updatedItemDefinitionsByName .forEach(itemDefinition -> { final String oldName = itemDefinition.getName().getValue(); final String newName = oldName.replaceAll("^" + oldModelName, newModelName); final Name name = new Name(newName); itemDefinition.setName(name); notifyPropertiesPanel(oldName, newName); }); updatedItemDefinitionsByType .forEach(itemDefinition -> { final QName oldType = itemDefinition.getTypeRef(); final String newLocalPart = oldType.getLocalPart().replaceAll("^" + oldModelName, newModelName); final QName qName = new QName(oldType.getNamespaceURI(), newLocalPart, oldType.getPrefix()); itemDefinition.setTypeRef(qName); }); refreshDataTypesList(); }
ItemDefinitionHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); updatedItemDefinitionsByName .forEach(itemDefinition -> { final String oldName = itemDefinition.getName().getValue(); final String newName = oldName.replaceAll("^" + oldModelName, newModelName); final Name name = new Name(newName); itemDefinition.setName(name); notifyPropertiesPanel(oldName, newName); }); updatedItemDefinitionsByType .forEach(itemDefinition -> { final QName oldType = itemDefinition.getTypeRef(); final String newLocalPart = oldType.getLocalPart().replaceAll("^" + oldModelName, newModelName); final QName qName = new QName(oldType.getNamespaceURI(), newLocalPart, oldType.getPrefix()); itemDefinition.setTypeRef(qName); }); refreshDataTypesList(); } }
ItemDefinitionHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); updatedItemDefinitionsByName .forEach(itemDefinition -> { final String oldName = itemDefinition.getName().getValue(); final String newName = oldName.replaceAll("^" + oldModelName, newModelName); final Name name = new Name(newName); itemDefinition.setName(name); notifyPropertiesPanel(oldName, newName); }); updatedItemDefinitionsByType .forEach(itemDefinition -> { final QName oldType = itemDefinition.getTypeRef(); final String newLocalPart = oldType.getLocalPart().replaceAll("^" + oldModelName, newModelName); final QName qName = new QName(oldType.getNamespaceURI(), newLocalPart, oldType.getPrefix()); itemDefinition.setTypeRef(qName); }); refreshDataTypesList(); } @Inject  ItemDefinitionHandler(final ItemDefinitionUtils itemDefinitionUtils,
                                 final Event<RefreshDataTypesListEvent> refreshDataTypesListEvent,
                                 final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); updatedItemDefinitionsByName .forEach(itemDefinition -> { final String oldName = itemDefinition.getName().getValue(); final String newName = oldName.replaceAll("^" + oldModelName, newModelName); final Name name = new Name(newName); itemDefinition.setName(name); notifyPropertiesPanel(oldName, newName); }); updatedItemDefinitionsByType .forEach(itemDefinition -> { final QName oldType = itemDefinition.getTypeRef(); final String newLocalPart = oldType.getLocalPart().replaceAll("^" + oldModelName, newModelName); final QName qName = new QName(oldType.getNamespaceURI(), newLocalPart, oldType.getPrefix()); itemDefinition.setTypeRef(qName); }); refreshDataTypesList(); } @Inject  ItemDefinitionHandler(final ItemDefinitionUtils itemDefinitionUtils,
                                 final Event<RefreshDataTypesListEvent> refreshDataTypesListEvent,
                                 final PropertiesPanelNotifier panelNotifier); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName); }
ItemDefinitionHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); updatedItemDefinitionsByName .forEach(itemDefinition -> { final String oldName = itemDefinition.getName().getValue(); final String newName = oldName.replaceAll("^" + oldModelName, newModelName); final Name name = new Name(newName); itemDefinition.setName(name); notifyPropertiesPanel(oldName, newName); }); updatedItemDefinitionsByType .forEach(itemDefinition -> { final QName oldType = itemDefinition.getTypeRef(); final String newLocalPart = oldType.getLocalPart().replaceAll("^" + oldModelName, newModelName); final QName qName = new QName(oldType.getNamespaceURI(), newLocalPart, oldType.getPrefix()); itemDefinition.setTypeRef(qName); }); refreshDataTypesList(); } @Inject  ItemDefinitionHandler(final ItemDefinitionUtils itemDefinitionUtils,
                                 final Event<RefreshDataTypesListEvent> refreshDataTypesListEvent,
                                 final PropertiesPanelNotifier panelNotifier); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName);  }