/** * Test method for {@link * org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject#getProperty()}. */ @Test public void testGetProperty() { Catalog catalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog(); catalog.setName(CATALOG_NAME); IRepositoryViewObject mockViewObject = mock(IRepositoryViewObject.class); Property property = PropertiesFactory.eINSTANCE.createProperty(); when(mockViewObject.getProperty()).thenReturn(property); ConnectionItem connItem = PropertiesFactory.eINSTANCE.createConnectionItem(); Connection conn = ConnectionFactory.eINSTANCE.createConnection(); connItem.setConnection(conn); Catalog catalog2 = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog(); catalog2.setName(CATALOG_NAME); conn.getDataPackage().add(catalog2); property.setItem(connItem); MetadataCatalogRepositoryObject catalogRepObject = new MetadataCatalogRepositoryObject(mockViewObject, catalog); Property property2 = catalogRepObject.getProperty(); Assert.assertTrue(property2.equals(property)); Assert.assertTrue(catalog2.equals(catalogRepObject.getCatalog())); }
/* * (non-Javadoc) * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { mdmForm = new MDMForm(parent, connectionItem, existingNames, this); mdmForm.setReadOnly(!isRepositoryObjectEditable); AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() { public void checkPerformed(final AbstractForm source) { if (source.isStatusOnError()) { MDMWizardPage.this.setPageComplete(false); setErrorMessage(source.getStatus()); } else { MDMWizardPage.this.setPageComplete(isRepositoryObjectEditable); setErrorMessage(null); setMessage(source.getStatus(), source.getStatusLevel()); } } }; mdmForm.setListener(listener); setControl(mdmForm); if (connectionItem.getProperty().getLabel() != null && !connectionItem.getProperty().getLabel().equals("")) { // $NON-NLS-1$ mdmForm.checkFieldsValue(); } }
private boolean hasChildrenInDataBase() { boolean hasChildrenInDB = false; IRepositoryViewObject object = this.getParent().getObject(); if (object instanceof MetadataCatalogRepositoryObject) { viewObject = ((MetadataCatalogRepositoryObject) object).getViewObject(); item = (ConnectionItem) viewObject.getProperty().getItem(); connection = item.getConnection(); catalog = ((MetadataCatalogRepositoryObject) object).getCatalog(); try { hasChildrenInDB = DqRepositoryViewService.isCatalogHasChildren( connection, catalog, null, DqRepositoryViewService.VIEW_TYPES); } catch (Exception e) { log.error(e.toString()); } } else { viewObject = ((MetadataSchemaRepositoryObject) object).getViewObject(); item = (ConnectionItem) viewObject.getProperty().getItem(); connection = item.getConnection(); schema = ((MetadataSchemaRepositoryObject) object).getSchema(); try { hasChildrenInDB = DqRepositoryViewService.isSchemaHasChildren( connection, schema, null, DqRepositoryViewService.VIEW_TYPES); } catch (MissingDriverException e) { throw e; } catch (Exception e) { log.error(e.toString()); } } return hasChildrenInDB; }
/** * DOC plv Comment method "updateHDFSConnection". * * @param connectionItem * @param show * @param onlySimpleShow * @return */ public static boolean updateOozieConnection( ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) { List<Relation> relations = RelationshipItemBuilder.getInstance() .getItemsRelatedTo( connectionItem.getProperty().getId(), RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION); RepositoryUpdateManager repositoryUpdateManager = new RepositoryUpdateManager(connectionItem, relations) { @Override public Set<EUpdateItemType> getTypes() { Set<EUpdateItemType> types = new HashSet<EUpdateItemType>(); types.add(EUpdateItemType.NODE_PROPERTY); return types; } }; return repositoryUpdateManager.doWork(true, false); }
/** * Create TableFolderNodeRepositoryNode. * * @param node parent RepositoryNode * @param metadataObject parent CatalogViewObject or SchemaViewObject */ private void createRepositoryNodeViewFolderNode( List<IRepositoryNode> node, IRepositoryViewObject metadataObject) { List<TdView> views = new ArrayList<TdView>(); String filterCharacter = null; try { if (metadataObject instanceof MetadataCatalogRepositoryObject) { viewObject = ((MetadataCatalogRepositoryObject) metadataObject).getViewObject(); if (((MetadataCatalogRepositoryObject) metadataObject).getCatalog().eIsProxy()) { // reload the connection to make sure the connection(and all it's owned elements) is not // proxy reloadConnectionViewObject(); } catalog = ((MetadataCatalogRepositoryObject) metadataObject).getCatalog(); item = (ConnectionItem) viewObject.getProperty().getItem(); views = PackageHelper.getViews(catalog); filterCharacter = RepositoryNodeHelper.getViewFilter(catalog, schema); // MOD gdbu 2011-6-29 bug : 22204 // MOD TDQ-8718 20140505 yyin --the repository view cares about if use the filter or not, // the column // select dialog cares about if connect to DB or not. if (views.isEmpty()) { connection = item.getConnection(); if (isCallingFromColumnDialog()) { views = DqRepositoryViewService.getViews(connection, catalog, null, isLoadDBFromDialog()); } else if (!isOnFilterring()) { // MOD gdbu 2011-7-21 bug 23220 views = DqRepositoryViewService.getViews(connection, catalog, null, true); } if (views != null && views.size() > 0) { ProxyRepositoryFactory.getInstance().save(item, false); } } ConnectionUtils.retrieveColumn(views); // ~22204 } else if (metadataObject instanceof MetadataSchemaRepositoryObject) { viewObject = ((MetadataSchemaRepositoryObject) metadataObject).getViewObject(); if (((MetadataSchemaRepositoryObject) metadataObject).getSchema().eIsProxy()) { // reload the connection to make sure the connection(and all it's owned elements) is not // proxy reloadConnectionViewObject(); } schema = ((MetadataSchemaRepositoryObject) metadataObject).getSchema(); item = (ConnectionItem) viewObject.getProperty().getItem(); views = PackageHelper.getViews(schema); filterCharacter = RepositoryNodeHelper.getViewFilter(catalog, schema); RepositoryNode parent = metadataObject.getRepositoryNode().getParent(); IRepositoryViewObject object = parent.getObject(); if (object instanceof MetadataCatalogRepositoryObject && filterCharacter.equals(PluginConstant.EMPTY_STRING)) { filterCharacter = RepositoryNodeHelper.getViewFilter( ((MetadataCatalogRepositoryObject) object).getCatalog(), null); } // MOD gdbu 2011-6-29 bug : 22204 if (views.isEmpty()) { connection = item.getConnection(); if (isCallingFromColumnDialog()) { views = DqRepositoryViewService.getViews(connection, schema, null, isLoadDBFromDialog()); } else if (!isOnFilterring()) { // MOD gdbu 2011-7-21 bug 23220 views = DqRepositoryViewService.getViews(connection, schema, null, true); } if (views != null && views.size() > 0) { ProxyRepositoryFactory.getInstance().save(item, false); } } else { ConnectionUtils.retrieveColumn(views); } // ~22204 } } catch (Exception e) { log.error(e, e); } if (filterCharacter != null && !filterCharacter.equals(PluginConstant.EMPTY_STRING)) { views = RepositoryNodeHelper.filterViews(views, filterCharacter); } createViewRepositoryNode(views, node); }