Interface ExtractManager


@OpenApiAll public interface ExtractManager
A class responsible for extract refactoring. Use the Refactoring.Extracting class to create the extract manager for a symbol which you want to extract. Configure the extract refactoring by changing ExtractSource and ExtractTarget. Invoke the refactoring with RefactorManager.refactor(). Review refactoring results by inspecting ExtractSource and ExtractTarget.

 // Creates extract refactor manager.
 ExtractManager extractManager = Refactoring.Extracting.createExtractManager(symbols);

 if (extractManager != null)
 {
     // A session has to be started before refactoring.
     SessionManager sessionManager = SessionManager.getInstance();
     sessionManager.createSession("Extract Refactor Symbols");

     // We may control the extract refactor result by modifying extract target.
     ExtractTarget extractTarget = extractManager.getExtractTarget();

     // Create a namespace to which we are going to refactor.
     Project project = Project.getProject(symbols[0]);
     Package package1 = project.getElementsFactory().createPackageInstance();
     package1.setOwner(project.getModel());

     // Set the namespace to which the extract result will go.
     extractTarget.setTargetNamespace(package1);

     // Choose target diagram type from allowed diagram types if the default type does not suite.
     List allowedTargetDiagramTypes = extractTarget.getAllowedTargetDiagramTypes();
     extractTarget.setTargetDiagramType(allowedTargetDiagramTypes.get(0));

     // Modify reference names which link the extract refactor source to the target.
     List<? extends ExtractReference> references = extractTarget.getReferences();

     for (int i = 0; i < references.size(); i++)
     {
         ExtractReference reference = references.get(i);
         reference.setName(Integer.toString(i));
     }

     // We may control the extract refactor source by modifying the extract source.
     ExtractSource extractSource = extractManager.getExtractSource();
     extractSource.setElementName("sourceElementName");

     // Perform actual refactoring.
     extractManager.extract();

     sessionManager.closeSession();

     // The element which was created in the source during refactoring.
     Element sourceElement = extractSource.getElement();

     // The element which was created in the target during refactoring.
     Element targetElement = extractTarget.getElement();

     // The diagram which was created in the target during refactoring.
    DiagramPresentationElement targetDiagram = extractTarget.getDiagram();
 }
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Performs actual extract refactoring of the model.
    Gets extract refactor source end of extract refactoring.
    Gets extract refactor target which is used to customize the extracted result.
  • Method Details

    • extract

      boolean extract()
      Performs actual extract refactoring of the model. Wrap the call of this method with session create/close.
      Returns:
      true if refactoring was successful, false otherwise.
    • getExtractTarget

      ExtractTarget getExtractTarget()
      Gets extract refactor target which is used to customize the extracted result.
      Returns:
      extract refactor target.
    • getExtractSource

      ExtractSource getExtractSource()
      Gets extract refactor source end of extract refactoring.
      Returns:
      extract refactor source.