public static boolean verifica() {
    executeInjection();

    NewMappingTaskPM newMappingTaskPM =
        (NewMappingTaskPM) modello.getBean(Costanti.NEW_MAPPING_TASK_PM);
    String sourceElement = newMappingTaskPM.getSourceElement();
    if (sourceElement.equals(
        NbBundle.getMessage(Costanti.class, Costanti.DATASOURCE_TYPE_RELATIONAL))) {
      // RELATIONAL
      RelationalConfigurationPM relationalConfigurationPM =
          (RelationalConfigurationPM) modello.getBean(Costanti.RELATIONAL_CONFIGURATION_SOURCE);
      return relationalConfigurationPM.checkFieldsAccessConfiguration();
    } else if (sourceElement.equals(
        NbBundle.getMessage(Costanti.class, Costanti.DATASOURCE_TYPE_XML))) {
      // XML
      XMLConfigurationPM xmlConfigurationPM =
          (XMLConfigurationPM) modello.getBean(Costanti.XML_CONFIGURATION_SOURCE);
      return xmlConfigurationPM.checkFieldsForSource();
    } else if (sourceElement.equals(
        NbBundle.getMessage(Costanti.class, Costanti.DATASOURCE_TYPE_SQL))) {
      // SQL
      SQLConfigurationPM sqlConfigurationPM =
          (SQLConfigurationPM) modello.getBean(Costanti.SQL_CONFIGURATION_SOURCE);
      return (sqlConfigurationPM.checkFileFields() && sqlConfigurationPM.checkDatabaseNameField());
    } else {
      // giannisk CSV (default value)
      // also checks for null Database Name
      CSVConfigurationPM csvConfigurationPM =
          (CSVConfigurationPM) modello.getBean(Costanti.CSV_CONFIGURATION_SOURCE);
      return (csvConfigurationPM.checkFileFields() && csvConfigurationPM.checkDatabaseNameField());
    }
  }
示例#2
0
  @Override
  public void performAction() {
    Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
    MappingTask mappingTask = scenario.getMappingTask();

    JFileChooser chooser = vista.getFileChooserApriTXT();
    File file;
    continua = true;
    while (continua) {
      int returnVal =
          chooser.showDialog(
              WindowManager.getDefault().getMainWindow(),
              NbBundle.getMessage(Costanti.class, Costanti.EXPORT_TGDS));
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
        if (!file.exists()) {
          saveTGDs(mappingTask, file);
        } else {
          confirmSave(mappingTask, file);
        }
      } else {
        continua = false;
      }
    }
    /*    List<FORule> foRules = mappingTask.getMappingData().getSTTgds();
    for (FORule foRule : foRules) {
        System.out.println(foRule.toLogicalString(mappingTask));
    }*/
  }
 private void openTransformationWindows() {
   Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
   TransformationTopComponent transformationTopComponent =
       scenario.getTransformationTopComponent();
   if (transformationTopComponent == null) {
     transformationTopComponent = new TransformationTopComponent(scenario);
     scenario.setTransformationTopComponent(transformationTopComponent);
   }
   transformationTopComponent.clear();
   this.viewTransformationAction.performAction();
 }
示例#4
0
  @Override
  public void performAction() {
    Properties config = new Properties();
    config.setProperty(
        IComputeQuality.class.getSimpleName(),
        "it.unibas.spicy.findmappings.strategies.computequality.ComputeQualityStructuralAnalysis");
    Application.reset(config);
    executeInjection();
    mappingFinder.cleanUp();
    Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
    MappingTask mappingTask = scenario.getMappingTask();
    if (mappingTask.getTargetProxy().getInstances().isEmpty()) {
      NotifyDescriptor nd =
          new NotifyDescriptor.Message(
              NbBundle.getMessage(Costanti.class, Costanti.WARNING_NOT_TARGET_INSTANCES),
              DialogDescriptor.WARNING_MESSAGE);
      DialogDisplayer.getDefault().notify(nd);
      return;
    }
    checkValueCorrespondenceInMappingTask(mappingTask);
    SwingWorker swingWorker =
        new SwingWorker() {

          private Scenario scenario;

          @Override
          protected Object doInBackground() throws Exception {
            scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
            MappingTask mappingTask = scenario.getMappingTask();

            List<AnnotatedMappingTask> bestMappingTasks =
                mappingFinder.findBestMappings(mappingTask);
            modello.putBean(Costanti.BEST_MAPPING_TASKS, bestMappingTasks);
            IOProvider.getDefault().getIO(Costanti.FLUSSO_SPICY, false).select();
            return true;
          }

          @Override
          protected void done() {
            try {
              if ((Boolean) get() && !isCancelled()) {
                actionViewSpicy.performActionWithScenario(this.scenario);
                actionViewBestMappings.performActionWithScenario(this.scenario);
              }
            } catch (InterruptedException ex) {
              logger.error(ex);
            } catch (ExecutionException ex) {
              logger.error(ex);
            }
          }
        };
    swingWorker.execute();
  }
示例#5
0
 private void addCorrespondencesToCandidate(MappingTask mappingTask) {
   List<ValueCorrespondence> candidateCorrespondences = new ArrayList<ValueCorrespondence>();
   for (ValueCorrespondence valueCorrespondence : mappingTask.getValueCorrespondences()) {
     if (checkValueCorrespondences(valueCorrespondence)) {
       for (ValueCorrespondence candidateCorrespondence :
           mappingTask.getCandidateCorrespondences()) {
         if (valueCorrespondence.hasEqualPaths(candidateCorrespondence)) {
           candidateCorrespondences.add(candidateCorrespondence);
           break;
         }
       }
       mappingTask.addCandidateCorrespondence(valueCorrespondence);
     }
   }
   mappingTask.getValueCorrespondences().clear();
   mappingTask.getCandidateCorrespondences().removeAll(candidateCorrespondences);
   Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
   MappingTaskTopComponent mappingTaskTopComponent = scenario.getMappingTaskTopComponent();
   mappingTaskTopComponent.getJLayeredPane().getGlassPane().clearConnectionLayer();
 }
 @Override
 public void performAction() {
   Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
   MappingTask mappingTask = scenario.getMappingTask();
   if (mappingTask.getValueCorrespondences().size() == 0
       && mappingTask.getMappingData().getSTTgds().isEmpty()) {
     NotifyDescriptor nd =
         new NotifyDescriptor.Message(
             NbBundle.getMessage(Costanti.class, Costanti.EMPTY_CORRESPONDENCES),
             DialogDescriptor.WARNING_MESSAGE);
     DialogDisplayer.getDefault().notify(nd);
     return;
   }
   try {
     openTransformationWindows();
     openInstanceWindows();
     enableActions();
   } catch (Exception ex) {
     DialogDisplayer.getDefault()
         .notify(new NotifyDescriptor.Message(ex.getMessage(), DialogDescriptor.ERROR_MESSAGE));
   }
 }
 private void registraAzione() {
   lastActionBean = (LastActionBean) modello.getBean(Costanti.LAST_ACTION_BEAN);
   lastActionBean.addObserver(this);
 }
 private void openInstanceWindows() {
   Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
   InstancesTopComponent instancesTopComponent = scenario.getInstancesTopComponent();
   instancesTopComponent.clearTranslated();
   this.actionViewInstances.performAction();
 }