/**
   * 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);
  }
Exemplo n.º 2
0
 /**
  * @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;
 }
  /**
   * 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$
  }
Exemplo n.º 4
0
  /**
   * @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);
      }
    }
  }
  @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);
  }
 /**
  * @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);
 }
  /**
   * 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;
  }
Exemplo n.º 8
0
  /*
   * @see org.teiid.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
   */
  @Override
  public Properties getExtensionProperties(Object metadataID) {
    CoreArgCheck.isInstanceOf(MetadataRecord.class, metadataID);
    MetadataRecord metadataRecord = (MetadataRecord) metadataID;

    String uuid = metadataRecord.getUUID();
    EObject eObj = lookupEObject(uuid);

    Properties extProps = new Properties();

    // Create get annotation for the EObject and lookup properties
    if (eObj != null && eObj.eResource() != null && eObj.eResource() instanceof EmfResource) {
      EmfResource emfResource = (EmfResource) eObj.eResource();
      ModelContents contents = new ModelContents(emfResource);
      Annotation annotation = contents.getAnnotation(eObj);
      if (annotation != null) {
        Iterator entryIter = annotation.getTags().entrySet().iterator();
        while (entryIter.hasNext()) {
          Map.Entry entry = (Map.Entry) entryIter.next();
          extProps.setProperty((String) entry.getKey(), (String) entry.getValue());
        }
      }
    }

    return extProps;
  }
  /**
   * 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());
  }
Exemplo n.º 10
0
  /**
   * 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);
  }
Exemplo n.º 11
0
 /* (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);
 }
  public MappingClassColumn getMappingClassColumn(
      EObject theTreeNode, MappingClass theMappingClass) {
    CoreArgCheck.isNotNull(theTreeNode);

    MappingClassColumn result = mappingLocator.getMappingClassColumn(theTreeNode, theMappingClass);

    return result;
  }
  /**
   * @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));
  }
Exemplo n.º 14
0
  /**
   * Find the EObject having the specified UUID using the ObjectManager for the lookup. If an
   * EObject with this UUID cannot be found then null is returned.
   */
  protected EObject lookupEObject(final String uuid) {
    CoreArgCheck.isNotEmpty(uuid);

    // Before searching by UUID make sure all resources associated with this QMI are loaded
    if (this.getResources() != null) {
      for (Iterator iter = this.getResources().iterator(); iter.hasNext(); ) {
        Resource r = (Resource) iter.next();
        if (!r.isLoaded()) {
          try {
            r.load(Collections.EMPTY_MAP);
          } catch (IOException e) {
            TransformationPlugin.Util.log(IStatus.ERROR, e.getLocalizedMessage());
          }
        }
      }
    }

    // Go to the Container ...
    EObject eObject = null;

    if (this.getContainer() != null) {
      eObject = (EObject) this.getContainer().getEObjectFinder().find(uuid);

      if (eObject != null) {
        // get the resource on the object
        Resource resource = eObject.eResource();
        // check if this is among the resources is scope for this QMI
        if (this.getResources() != null) {
          Container cntr = ModelerCore.getContainer(resource);
          // If the resource exists in the same Container as the one associated with this QMI
          // but the resource is not in the scope of resources then return null
          if (cntr == this.getContainer() && !this.getResources().contains(resource)) {
            return null;
          }
        }
      }
      return eObject;
    }

    // We are in a non-container environment
    Iterator rsrs = this.getResources().iterator();
    while (rsrs.hasNext()) {
      Resource rsrc = (Resource) rsrs.next();
      if (rsrc instanceof MMXmiResource) {
        eObject = ((MMXmiResource) rsrc).getEObject(uuid);
        if (eObject != null) {
          return eObject;
        }
      } else if (rsrc instanceof XSDResourceImpl) {
        eObject = ((XSDResourceImpl) rsrc).getEObject(uuid);
        if (eObject != null) {
          return eObject;
        }
      }
    }

    return eObject;
  }
Exemplo n.º 15
0
 /**
  * @see
  *     org.teiid.designer.core.metamodel.aspect.sql.SqlTableAspect#isSystem(org.eclipse.emf.ecore.EObject)
  */
 @Override
 public boolean isSystem(EObject eObject) {
   CoreArgCheck.isInstanceOf(InputSet.class, eObject);
   String modelName = getModelName(eObject);
   if (modelName != null && SystemVdbUtility.isSystemModelWithSystemTableType(modelName)) {
     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);
      }
    }
  }
    /**
     * @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);
    }
  /**
   * 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
              }));
    }
  }
    /**
     * @param runtimeType the Teiid runtime type being converted (never <code>null</code> or empty)
     * @return the model extension property definition type (newver <code>null</code>)
     * @throws IllegalArgumentException if argument cannot be converted to a valid type
     */
    public static Type convertRuntimeType(String runtimeType) {
      CoreArgCheck.isNotEmpty(runtimeType, "runtimeType is empty"); // $NON-NLS-1$

      for (Type type : Type.values()) {
        if (type.getRuntimeType().equals(runtimeType)) {
          return type;
        }
      }

      throw new IllegalArgumentException(NLS.bind(Messages.invalidRuntimeType, runtimeType));
    }
 /**
  * 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;
 }
Exemplo n.º 21
0
 /**
  * Get the short element from the given full name
  *
  * @param fullElementName
  * @return
  */
 protected String getShortElementName(final String fullElementName) {
   CoreArgCheck.isNotEmpty(fullElementName);
   if (UuidUtil.isStringifiedUUID(fullElementName)) {
     return UuidUtil.stripPrefixFromUUID(fullElementName);
   }
   int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
   if (index >= 0) {
     return fullElementName.substring(index + 1);
   }
   return fullElementName;
 }
  /**
   * @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);
      }
    }
  }
  /**
   * 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();
    }
  }
Exemplo n.º 26
0
 /* (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;
 }
Exemplo n.º 27
0
  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;
  }
Exemplo n.º 28
0
  /**
   * @see
   *     org.teiid.designer.transformation.ui.builder.ILanguageObjectEditor#setLanguageObject(org.teiid.query.sql.LanguageObject)
   */
  @Override
  public void setLanguageObject(LanguageObject theLanguageObject) {
    if (theLanguageObject == null) {
      clear();
    } else {
      CoreArgCheck.isTrue(
          (theLanguageObject instanceof Constant),
          Util.getString(
              PREFIX + "invalidLanguageObject", // $NON-NLS-1$
              new Object[] {theLanguageObject.getClass().getName()}));

      model.setLanguageObject(theLanguageObject);
    }
  }
Exemplo n.º 29
0
  /**
   * @see
   *     org.teiid.designer.core.validation.ObjectValidationRule#validate(org.eclipse.emf.ecore.EObject,
   *     org.teiid.designer.core.validation.ValidationContext)
   * @since 4.2
   */
  public void validate(EObject eObject, ValidationContext context) {
    CoreArgCheck.isInstanceOf(XClass.class, eObject);

    final XClass xclass = (XClass) eObject;

    // Make sure the name is set ...
    final String name = xclass.getName();
    if (name == null || name.trim().length() == 0) {
      final ValidationResult result = new ValidationResultImpl(xclass);
      final String msg = ModelerCore.Util.getString("XClassNameRule.MissingName"); // $NON-NLS-1$
      final ValidationProblem problem = new ValidationProblemImpl(0, IStatus.ERROR, msg);
      result.addProblem(problem);
      context.addResult(result);
      return;
    }
  }
Exemplo n.º 30
0
 /** @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;
 }