/** * Removes the specified {@link org.eclipse.emf.mapping.Mapping}. * * @param theMappingColumn the <code>Mapping</code> input * @param theTreeNode the <code>Mapping</code> output * @throws IllegalArgumentException if either input parameter is <code>null</code> */ public void removeMappingClassColumnLocation( MappingClassColumn theMappingColumn, EObject theTreeNode) { CoreArgCheck.isNotNull(theMappingColumn); CoreArgCheck.isNotNull(theTreeNode); mappingLocator.removeMappingClassColumnLocation(theMappingColumn, theTreeNode); }
/** * Maps the specified <code>MappingClassColumn</code> to the specified tree node (<code>EObject * </code>). * * @param theMappingColumn the <code>Mapping</code> input * @param theTreeNode the <code>Mapping</code> output * @throws IllegalArgumentException if either input parameter is <code>null</code> */ public void addMappingClassColumnLocation( MappingClassColumn theMappingColumn, EObject theTreeNode) { // startTracking("addMappingClassColumnLocation()"); //$NON-NLS-1$ CoreArgCheck.isNotNull(theMappingColumn); CoreArgCheck.isNotNull(theTreeNode); mappingLocator.addMappingClassColumnLocation(theMappingColumn, theTreeNode); // stopTracking("addMappingClassColumnLocation()"); //$NON-NLS-1$ }
/** * @see * org.teiid.designer.core.validation.ObjectValidationRule#validate(org.eclipse.emf.ecore.EObject, * org.teiid.designer.core.validation.ValidationContext) * @since 4.2 */ @Override public void validate(final EObject eObject, final ValidationContext context) { CoreArgCheck.isNotNull(context); CoreArgCheck.isNotNull(eObject); // get uniqueness preference status final int status = context.getPreferenceStatus(ValidationPreferences.EOBJECT_UUID_UNIQUENESS, IStatus.ERROR); if (status == IStatus.OK) { return; } // if the eObject is a model annotation then // is already being validation by ModelAnnoattionUuidRule if (eObject instanceof ModelAnnotation) { return; } final ModelEditor editor = ModelerCore.getModelEditor(); final String uuidString = ModelerCore.getObjectIdString(eObject); if (uuidString == null) { final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString(); final ValidationResult result = new ValidationResultImpl(eObject); // create validation problem and add it to the result final ValidationProblem problem = new ValidationProblemImpl( 0, IStatus.ERROR, ModelerCore.Util.getString("EObjectUuidRule.0", pathInModel)); // $NON-NLS-1$ problem.setHasPreference(context.hasPreferences()); result.addProblem(problem); context.addResult(result); } else { boolean isDuplicate = context.containsUuid(uuidString); if (isDuplicate) { final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString(); final ValidationResult result = new ValidationResultImpl(eObject); String modelName = editor.getModelName(eObject); // create validation problem and addit to the result final ValidationProblem problem = new ValidationProblemImpl( 0, status, ModelerCore.Util.getString( "EObjectUuidRule.1", pathInModel, uuidString, modelName)); // $NON-NLS-1$ problem.setHasPreference(context.hasPreferences()); result.addProblem(problem); context.addResult(result); } else { context.addUuidToContext(uuidString); } } }
/** Export the current string content of the sql display to a user-selected file */ public File exportSqlToFile(String fileNameString, String fileExtension, String fileOuputString) { // PERFORM ARG CHECK // Look for NULL or EMPTY strings CoreArgCheck.isNotNull(fileNameString); CoreArgCheck.isNotNull(fileExtension); CoreArgCheck.isNotNull(fileOuputString); CoreArgCheck.isNotEmpty(fileNameString); CoreArgCheck.isNotEmpty(fileExtension); CoreArgCheck.isNotEmpty(fileOuputString); // If there is no file extension, add .sql if (fileNameString.indexOf('.') == -1 && fileExtension != null) { fileNameString = fileNameString + "." + fileExtension; // $NON-NLS-1$ } FileWriter fileWriter = null; BufferedWriter outputBufferWriter = null; PrintWriter printWriter = null; try { fileWriter = new FileWriter(fileNameString); outputBufferWriter = new BufferedWriter(fileWriter); printWriter = new PrintWriter(outputBufferWriter); printWriter.write(fileOuputString); } catch (Exception e) { UiConstants.Util.log(IStatus.ERROR, e, UiConstants.Util.getString(EXPORT_PROBLEM)); } finally { // Clean up writers & buffers if (printWriter != null) { printWriter.close(); } try { if (outputBufferWriter != null) { outputBufferWriter.close(); } } catch (java.io.IOException e) { } try { if (fileWriter != null) { fileWriter.close(); } } catch (java.io.IOException e) { } } return new File(fileNameString); }
/** * Append the specified IEntryResult[] to the IEntryResult to create a single result representing * an index entry that was split across multiple index records. * * @param result * @param continuationResults * @param blockSize */ public static IEntryResult joinEntryResults( final IEntryResult result, final IEntryResult[] continuationResults, final int blockSize) { CoreArgCheck.isNotNull(result); // If the IEntryResult is not continued on another record, return the original char[] baseResult = result.getWord(); if (baseResult.length < blockSize || baseResult[blockSize - 1] != IndexConstants.RECORD_TYPE.RECORD_CONTINUATION) { return result; } // Extract the UUID string from the original result String baseStr = new String(baseResult); String objectID = extractUUIDString(result); // Create and initialize a StringBuffer to store the concatenated result StringBuffer sb = new StringBuffer(); sb.append(baseStr.substring(0, blockSize - 1)); // Append the continuation results onto the original - // assumes the IEntryResult[] are in ascending order of segment number final IEntryResult[] sortedResults = sortContinuationResults(objectID, continuationResults); for (int i = 0; i < sortedResults.length; i++) { char[] continuation = sortedResults[i].getWord(); int segNumber = getContinuationSegmentNumber(objectID, sortedResults[i]); int beginIndex = objectID.length() + Integer.toString(segNumber).length() + 5; for (int j = beginIndex; j < continuation.length; j++) { if (j < blockSize - 1) { sb.append(continuation[j]); } } } return new EntryResult(sb.toString().toCharArray(), result.getFileReferences()); }
@Override public ModelWorkspaceItem getParent(final IResource resource) { CoreArgCheck.isNotNull(resource); IProject project = resource.getProject(); if (project.isAccessible() && !ModelerCore.hasModelNature(project)) { return null; } // If the resource is an IProject... return the resource if (resource instanceof IProject) { return this; } // If the parent is null, return null final IResource parent = resource.getParent(); if (parent == null) { return null; } // Calculate the parent path from the given resource final IPath path = resource.getFullPath(); final IPath parentPath = path.removeLastSegments(1); // Find the workspaceItem for the parent path1 return getWorkspaceItem(parentPath); }
/** * Creates a {@link MappingRoot} having the specified <code>MappingClass</code> as it's input. * * @param theMappingClass the <code>MappingClass</code> used to create the mapping root * @return the index in the <code>mappingRoots</code> list of the new root * @throws IllegalArgumentException if input parameter is <code>null</code> */ public EObject createTreeMappingRoot(MappingClass theMappingClass) { // startTracking("createTreeMappingRoot(GENERATING)"); //$NON-NLS-1$ CoreArgCheck.isNotNull(theMappingClass); if (mappingLocator.hasTreeRoot(theMappingClass)) { return mappingLocator.getMappingRoot(theMappingClass); } TreeMappingRoot newRoot = null; try { // Defect 18433 - BML 8/31/05 - Changed call to create tree mapping root using a new // utility method that correctly adds it to the model (via addValue()) and also performs // additional work (i.e.adding nested Sql Helpers. newRoot = ModelResourceContainerFactory.createNewTreeMappingRoot(this.root, this.root.eResource()); // Now add the mapping class to the Inputs list of the tree mapping root ModelerCore.getModelEditor().addValue(newRoot, theMappingClass, newRoot.getInputs()); } catch (Exception theException) { Util.log( IStatus.ERROR, theException, Util.getString( PREFIX + "createMappingRootProblem", // $NON-NLS-1$ new Object[] {root, theMappingClass})); } // stopTracking("createTreeMappingRoot(GENERATING)"); //$NON-NLS-1$ return newRoot; }
/** * @see org.teiid.designer.core.workspace.ModelWorkspace#createModelProject(java.lang.String, * java.lang.String, org.eclipse.core.runtime.IProgressMonitor) * @since 4.0 */ @Override public ModelProject createModelProject( final String name, final IPath path, final IProgressMonitor monitor) throws CoreException { CoreArgCheck.isNotNull(name); // Check if project already exists if (findModelProject(name) != null) { throw new ModelWorkspaceException( ModelerCore.Util.getString( "ModelWorkspaceImpl.cannotCreateModelProject", name)); // $NON-NLS-1$ } // Validate name final IWorkspace workspace = ModelerCore.getWorkspace(); final IStatus status = workspace.validateName(name, IResource.PROJECT); if (!status.isOK()) { throw new ModelWorkspaceException( new ModelStatusImpl(status.getSeverity(), status.getCode(), status.getMessage())); } // Create new model project final IProject project = workspace.getRoot().getProject(name); final IProjectDescription desc = workspace.newProjectDescription(project.getName()); desc.setLocation(path); desc.setNatureIds(MODEL_NATURES); final IWorkspaceRunnable op = new IWorkspaceRunnable() { @Override public void run(final IProgressMonitor monitor) throws CoreException { project.create(desc, monitor); project.open(monitor); } }; workspace.run(op, monitor); return new ModelProjectImpl(project, this); }
/* (non-Javadoc) * @See org.teiid.designer.core.workspace.ModelWorkspace#findModelResource(org.eclipse.emf.ecore.resource.Resource) */ @Override public ModelResource findModelResource(final IResource resource) { CoreArgCheck.isNotNull(resource); if (!ModelUtil.isModelFile(resource)) { return null; } return (ModelResource) getWorkspaceItem(resource.getFullPath(), IResource.FILE); }
/** * @param info the import data (cannot be <code>null</code>) * @since 4.0 */ public TeiidMetadataImportFormatPage(TeiidMetadataImportInfo info) { super(TeiidMetadataImportFormatPage.class.getSimpleName(), TITLE); CoreArgCheck.isNotNull(info, "info"); // $NON-NLS-1$ this.info = info; setImageDescriptor(UiPlugin.getDefault().getImageDescriptor(Images.IMPORT_TEIID_METADATA)); }
public MappingClassColumn getMappingClassColumn( EObject theTreeNode, MappingClass theMappingClass) { CoreArgCheck.isNotNull(theTreeNode); MappingClassColumn result = mappingLocator.getMappingClassColumn(theTreeNode, theMappingClass); return result; }
/** * @see * org.teiid.designer.core.metamodel.aspect.sql.SqlTableAspect#canBeTransformationSource(org.eclipse.emf.ecore.EObject, * org.eclipse.emf.ecore.EObject) * @since 4.3 */ @Override public boolean canBeTransformationSource(EObject source, EObject target) { CoreArgCheck.isInstanceOf(InputSet.class, source); CoreArgCheck.isNotNull(target); if (target instanceof MappingClass && !(target instanceof StagingTable)) { return true; } return false; }
/** Add the specified list any external resource for this EReference feature */ protected void processReferenceValue( final Resource eResource, final EObject eObject, final EReference eReference, final EObject value, final List externalResources, final Set unresolvedResourceURIs) { if (value == null) { return; } // Check if the object is an EMF proxy ... if (value.eIsProxy()) { if (value instanceof InternalEObject) { final InternalEObject iObject = (InternalEObject) value; final URI proxyUri = iObject.eProxyURI(); CoreArgCheck.isNotNull(proxyUri); // Get the URI of the resource ... URI resourceUri = proxyUri.trimFragment(); // Make the relative URI absolute if necessary URI baseLocationUri = eResource.getURI(); URI proxyLocationUri = UriHelper.makeAbsoluteUri(baseLocationUri, resourceUri); // URI proxyLocationUri = resourceUri; // if (baseLocationUri.isHierarchical() && !baseLocationUri.isRelative() && // proxyUri.isRelative()) { // proxyLocationUri = proxyLocationUri.resolve(baseLocationUri); // } Resource rsrc = findByURI(proxyLocationUri, true); // If the resource URI is a workspace relative path (e.g. "/project/.../model.xmi") if (rsrc == null && baseLocationUri.isFile() && resourceUri.toString().charAt(0) == '/') { String baseLocation = URI.decode(baseLocationUri.toFileString()); String projectName = resourceUri.segment(0); String proxyLocation = URI.decode(resourceUri.toString()); int index = baseLocation.indexOf(projectName); if (index != -1) { proxyLocation = baseLocation.substring(0, index - 1) + proxyLocation; rsrc = findByURI(URI.createFileURI(proxyLocation), true); } } if (rsrc != null && eResource != rsrc && !externalResources.contains(rsrc)) { externalResources.add(rsrc); } else if (rsrc == null) { unresolvedResourceURIs.add(resourceUri); } } } else { Resource rsrc = value.eResource(); if (eResource != rsrc && !externalResources.contains(rsrc)) { externalResources.add(rsrc); } } }
/** * Removes the specified {@link org.eclipse.emf.mapping.Mapping}. * * @param theMappingClass the <code>Mapping</code> input * @param theTreeNode the <code>Mapping</code> output * @throws IllegalArgumentException if either input parameter is <code>null</code> */ public void removeMappingClassLocation(MappingClass theMappingClass, EObject theTreeNode) { CoreArgCheck.isNotNull(theMappingClass); CoreArgCheck.isNotNull(theTreeNode); try { mappingLocator.removeOutputLocation(theMappingClass, theTreeNode); } catch (Exception e) { Util.log( IStatus.ERROR, e, Util.getString( PREFIX + "removeLocationTreeNodeNotFound", // $NON-NLS-1$ new Object[] { theTreeNode, "MappingClass", //$NON-NLS-1$ theMappingClass })); } }
/** * Return the MappingClass located at the specified node, if one exists at this node. * * @param theTreeNode * @return */ public EObject getMappingClassLocation(MappingClass theMappingClass) { // startTracking("getMappingClassLocation()"); //$NON-NLS-1$ CoreArgCheck.isNotNull(theMappingClass); List locations = mappingLocator.getMappingClassLocations(theMappingClass); EObject location = null; if (!locations.isEmpty()) { location = (EObject) locations.get(0); } // stopTracking("getMappingClassLocation()"); //$NON-NLS-1$ return location; }
/** * Constructs a <code>TreeMappingAdapter</code> for the specified tree root. * * @param theTreeRoot the tree root */ public TreeMappingAdapter(EObject theTreeRoot) { // startTracking("TreeMappingAdapter()"); //$NON-NLS-1$ CoreArgCheck.isNotNull(theTreeRoot); mappingLocator = new TreeMappingClassLocator(theTreeRoot); root = theTreeRoot; mappingLocator.loadTreeNodesToMappingClassScopeMap(); // stopTracking("TreeMappingAdapter()"); //$NON-NLS-1$ }
/** * Maps the specified <code>MappingClass</code> to the specified tree node (<code>EObject</code>). * * @param theMappingClass the <code>Mapping</code> input * @param theTreeNode the <code>Mapping</code> output * @throws IllegalArgumentException if either input parameter is <code>null</code> */ public void addMappingClassLocation(MappingClass theMappingClass, EObject theTreeNode) { // startTracking("addMappingClassLocation()"); //$NON-NLS-1$ CoreArgCheck.isNotNull(theMappingClass); CoreArgCheck.isNotNull(theTreeNode); if (!mappingLocator.containsLocation(theMappingClass, theTreeNode)) { try { TreeMappingRoot treeMappingRoot = (TreeMappingRoot) mappingLocator.getMappingRoot(theMappingClass); mappingLocator.addOutputLocation(theMappingClass, theTreeNode); // if( !isGeneratingMappingClasses() ) { addMappingClassAtLocation(treeMappingRoot, theMappingClass, theTreeNode); // } } catch (Exception e) { PluginConstants.Util.log(IStatus.ERROR, e, e.getMessage()); } } // stopTracking("addMappingClassLocation()"); //$NON-NLS-1$ }
/** * Construct an instance of ModelWorkspaceNotificationImpl. * * @param eventType * @param delta * @param isPre * @param isAutoBuild */ public ModelWorkspaceNotificationImpl( final int eventType, final IResourceDelta delta, final IResourceChangeEvent event) { super(eventType, null, delta); CoreArgCheck.isNotNull(event); this.delta = delta; this.event = event; if (delta != null) { this.notifier = delta.getResource(); } else { this.notifier = event.getResource(); } }
public ModelWorkspaceItem getWorkspaceItem(final IPath path, int resourceType) { CoreArgCheck.isNotNull(path); try { // first get all the projects ModelProject[] projects = getModelProjects(); for (int i = 0; i < projects.length; i++) { ModelProject project = projects[i]; if (resourceType == IResource.PROJECT) { if (project.getPath().equals(path)) { return project; } } else { if (!project.isOpen()) { continue; } // If the path only contains the project then we cannot match it // to a non-project type so return null if (path.segmentCount() < 2) { return null; } // If the first segment is not this project's name then skip it if (!path.segment(0).equals(project.getProject().getName())) { continue; } // Iterate over all the path segments navigating to the child by name ModelWorkspaceItem item = project; final String[] segments = path.segments(); for (int j = 1; j < segments.length; j++) { final String segment = segments[j]; if (!item.exists()) { // Must be in the process of closing (see defect 10957) ... return null; } item = item.getChild(segment); if (item == null) { break; } else if (item.getPath().makeRelative().equals(path.makeRelative())) { return item; } } // ModelWorkspaceItem[] children = project.getChildren(); // return recursiveLookUp(children, path); } } } catch (ModelWorkspaceException e) { // do nothing } return null; }
/* (non-Javadoc) * @See org.teiid.designer.core.workspace.ModelWorkspace#findModelResource(org.eclipse.emf.ecore.EObject) */ @Override public ModelResource findModelResource(final EObject eObject) { CoreArgCheck.isNotNull(eObject); try { final Container container = ModelerCore.getModelContainer(); Resource resource = ModelerCore.getModelEditor().findResource(container, eObject, false); if (resource != null) { return findModelResource(resource); } } catch (CoreException err) { ModelerCore.Util.log(err); } return null; }
/** @see org.teiid.designer.core.workspace.ModelWorkspace#findModelProject(java.lang.String) */ @Override public ModelProject findModelProject(final String name) { CoreArgCheck.isNotNull(name); try { final ModelProject[] projects = getModelProjects(); for (int ndx = projects.length; --ndx >= 0; ) { final ModelProject project = projects[ndx]; if (name.equals(project.getItemName())) { return project; } } } catch (ModelWorkspaceException e) { ModelerCore.Util.log(e); } return null; }
/** * Search for and return the version number associated with this record. If no version information * is found encoded in the record then the version number of NONVERSIONED_RECORD_INDEX_VERSION * will be returned. * * @param record * @since 4.2 */ public static int getIndexVersion(final char[] record) { CoreArgCheck.isNotNull(record); int endIndex = record.length; int beginIndex = (endIndex - 6 > 0 ? endIndex - 6 : 1); int version = NONVERSIONED_RECORD_INDEX_VERSION; for (int i = beginIndex; i < endIndex; i++) { if (record[i] == IndexConstants.RECORD_STRING.INDEX_VERSION_MARKER) { char versionPart1 = record[i + 1]; char versionPart2 = record[i + 2]; if (Character.isDigit(versionPart1) && Character.isDigit(versionPart2)) { version = Character.digit(versionPart1, 10) * 10 + Character.digit(versionPart2, 10); } } } return version; }
/** * Extract the UUID string from the IEntryResult * * @param result */ public static String extractUUIDString(final IEntryResult result) { CoreArgCheck.isNotNull(result); char[] word = result.getWord(); String baseStr = new String(word); int beginIndex = baseStr.indexOf(UUID.PROTOCOL); int endIndex = word.length; CoreArgCheck.isNonNegative(beginIndex); for (int i = beginIndex; i < word.length; i++) { if (word[i] == IndexConstants.RECORD_STRING.RECORD_DELIMITER) { endIndex = i; break; } } CoreArgCheck.isTrue(beginIndex < endIndex, "begin index should be less than end index"); return baseStr.substring(beginIndex, endIndex); }
/** @see org.teiid.designer.core.container.ObjectManager#findEObject(java.lang.String) */ @Override public EObject findEObject(String id) { CoreArgCheck.isNotNull(id); // loop through resource sets resources, calling resource.getEObject() for (Resource resrc : container.getResources()) { if (resrc.isLoaded()) { EObject obj = findEObject(id, resrc); if (obj != null) { return obj; } } } // check unattached objects // return MtkXmiResourceImpl.DETACHED_UUID_TO_EOBJECT_MAP.get(id); return null; }
/** * @param propId the property ID being checked (cannot be <code>null</code> or empty) * @param namespaceProvider the namespace provider used to determine the result (cannot be * <code>null</code>) * @return <code>true</code> if the identifier is a property definition ID for the specified * namespace provider */ public static boolean isExtensionPropertyId( String propId, NamespaceProvider namespaceProvider) { CoreArgCheck.isNotEmpty(propId, "propId is empty"); // $NON-NLS-1$ CoreArgCheck.isNotNull(namespaceProvider, "namespaceProvider is null"); // $NON-NLS-1$ String nsPrefix = namespaceProvider.getNamespacePrefix(); if (CoreStringUtil.isEmpty(nsPrefix)) { return false; } String propNsPrefix = getNamespacePrefix(propId); if (CoreStringUtil.isEmpty(propNsPrefix)) { return false; } return propNsPrefix.equals(nsPrefix); }
/** * @see * org.teiid.designer.core.validation.ObjectValidationRule#validate(org.eclipse.emf.ecore.EObject, * org.teiid.designer.core.validation.ValidationContext) * @since 4.2 */ @Override public void validate(final EObject eObject, final ValidationContext context) { CoreArgCheck.isNotNull(context); CoreArgCheck.isInstanceOf(ModelAnnotation.class, eObject); final ModelEditor editor = ModelerCore.getModelEditor(); String uuidString = ModelerCore.getObjectIdString(eObject); if (uuidString == null) { final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString(); final ValidationResult result = new ValidationResultImpl(eObject); // create validation problem and add it to the result final ValidationProblem problem = new ValidationProblemImpl( 0, IStatus.ERROR, ModelerCore.Util.getString("ModelAnnotationUuidRule.0", pathInModel)); // $NON-NLS-1$ result.addProblem(problem); context.addResult(result); } else { boolean isDuplicate = context.containsUuid(uuidString); if (isDuplicate) { final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString(); final ValidationResult result = new ValidationResultImpl(eObject); String modelName = editor.getModelName(eObject); // create validation problem and addit to the result final ValidationProblem problem = new ValidationProblemImpl( 0, IStatus.ERROR, ModelerCore.Util.getString( "ModelAnnotationUuidRule.1", pathInModel, uuidString, modelName)); //$NON-NLS-1$ result.addProblem(problem); context.addResult(result); } else { context.addUuidToContext(uuidString); } } }
/** * {@inheritDoc} * * @see org.teiid.designer.core.container.ObjectManager#getObjectId(org.eclipse.emf.ecore.EObject) */ @Override public String getObjectId(EObject object) { CoreArgCheck.isNotNull(object); Resource resrc = object.eResource(); if (resrc == null) { // check unattached objects return MtkXmiResourceImpl.DETACHED_EOBJECT_TO_UUID_MAP.get(object); } String uuid = resrc instanceof XResource ? ((XResource) resrc).getUuid(object) : resrc.getURIFragment(object); if ((uuid != null) && uuid.startsWith(UUID.PROTOCOL)) { return uuid; } return null; }
protected void handleSetSelected() { editor.save(); // need the editor's language object in order to update tree. // the language object should never be null. if it was this handler should not have been called ILanguageObject langObj = editor.getLanguageObject(); CoreArgCheck.isNotNull( langObj, Util.getString( PREFIX + "nullLangObj", // $NON-NLS-1$ new Object[] {"handleSetSelected"})); // $NON-NLS-1$ // update tree treeViewer.modifySelectedItem(langObj, false); // update SQL text setCurrentSql(treeViewer.getLanguageObject()); // put focus back on editor from the set button editor.acceptFocus(); }
/** @see org.teiid.designer.core.workspace.ModelWorkspace#findModelResource(IPath) */ @Override public ModelResource findModelResource(final IPath pathInWorkspace) { CoreArgCheck.isNotNull(pathInWorkspace); try { ModelWorkspaceItem item = this; final String[] segments = pathInWorkspace.segments(); for (int i = 0; i < segments.length; ++i) { final String segment = segments[i]; if (item == null) { break; } item = item.getChild(segment); } if (item == null || item.getItemType() != ModelWorkspaceItem.MODEL_RESOURCE) { return null; } return (ModelResource) item; } catch (ModelWorkspaceException e) { ModelerCore.Util.log(e); } return null; }
/** * Obtains the <code>MappingClassColumn</code> where the specified tree node is mapped. * * @param theTreeNode the tree node whose <code>MappingClassColumn</code> is being requested * @return the <code>MappingClassColumn</code> or <code>null</code> if not mapped */ public MappingClassColumn getMappingClassColumn(EObject theTreeNode) { /* * jh Lyra enh: * * This is a linear search, and the MCs are not necessarily in any * optimal order. Let's replace this with a HashMap. * * jhTODO * Major question: This map is created in the constructor of this class; * Should it be recreated any other times prior to * recreating this class (TreeMappingAdapter)? * Yes: on NewMappingLinkAction and DeleteMappingLinksAction * [fixed 2/1/2006] */ CoreArgCheck.isNotNull(theTreeNode); MappingClassColumn result = mappingLocator.getMappingClassColumn(theTreeNode); // // result = (MappingClassColumn)getTreeNodesToMappingClassColumnsMap( false ).get( // theTreeNode ); // return result; }