Exemplo n.º 1
0
  private void setVariables(Field.BeanTableField beanTableField) {
    List<ThreddsMetadata.Variables> variableLists = dataset.getLocalMetadata().getVariables();
    if ((variableLists != null) && (variableLists.size() > 0)) {
      ThreddsMetadata.Variables vars = variableLists.get(0);
      beanTableField.setValue(vars.getVariableList());
      setMode(beanTableField, 0);
      return;
    }

    variableLists = dataset.getLocalMetadataInheritable().getVariables();
    if ((variableLists != null) && (variableLists.size() > 0)) {
      ThreddsMetadata.Variables vars = variableLists.get(0);
      beanTableField.setValue(vars.getVariableList());
      setMode(beanTableField, 1);
      return;
    }

    variableLists = dataset.getVariables();
    if ((variableLists != null) && (variableLists.size() > 0)) {
      ThreddsMetadata.Variables vars = variableLists.get(0);
      beanTableField.setValue(vars.getVariableList());
      setMode(beanTableField, vars.getVariableList().size() == 0 ? 1 : 2);
      return;
    }

    // clear out the table
    beanTableField.setValue(new ArrayList());
  }
Exemplo n.º 2
0
  private void extractVariables() {
    if (leafDataset == null) leafDataset = findLeafDataset(dataset);
    if (leafDataset == null) return;

    ThreddsMetadata.Variables vars;
    try {
      vars = MetadataExtractor.extractVariables(leafDataset);
    } catch (IOException e) {
      return;
    }

    if (vars != null) {
      ThreddsMetadata tm = dataset.getLocalMetadataInheritable();
      List<ThreddsMetadata.Variables> varsList = tm.getVariables();
      boolean replaced = false;
      for (int i = 0; i < varsList.size(); i++) {
        ThreddsMetadata.Variables vs = varsList.get(i);
        if (vs.getVocabulary().equals(vars.getVocabulary())) {
          varsList.set(i, vars); // replace
          replaced = true;
          break;
        }
      }
      if (!replaced) tm.addVariables(vars);

      variablesFld.setValue(vars.getVariableList());
      setMode(variablesFld, 1);
    }
  }
Exemplo n.º 3
0
  private InvDatasetImpl getLeafDataset(InvDatasetImpl ds) {
    if (ds == null) return null;
    System.out.println("getLeafDataset " + ds.getFullName());
    List nestedList = ds.getDatasets();
    for (int i = 0; i < nestedList.size(); i++) {
      InvDatasetImpl nestedDS = (InvDatasetImpl) nestedList.get(i);

      if (nestedDS.hasAccess() && !nestedDS.hasNestedDatasets()) {
        InvDatasetImpl result =
            chooseLeafDataset(nestedList); // this assumes that they are uniform !!
        return (result.hasAccess()) ? result : nestedDS;
      }

      // depth first
      InvDatasetImpl leaf = getLeafDataset(nestedDS);
      if (leaf != null) return leaf;
    }

    return null;
  }
Exemplo n.º 4
0
  public void store2Dataset() {
    PersistentBean persBean = new PersistentBean(dataset); // reset the BeanMaps

    setStoreValue(NAME, persBean, false);
    setStoreValue(ID, persBean, false);

    setStoreValue(AUTHORITY, persBean, true);
    setStoreValue(SERVICE_NAME, persBean, true);

    setStoreValue(FORMAT_TYPE, persBean, true);
    setStoreValue(DATA_TYPE, persBean, true);

    setStoreValue(COLLECTION_TYPE, persBean, false);
    setStoreValue(HARVEST, persBean, false);

    String gcType = (String) metadataPP.getFieldValue(GC_TYPE);
    if (!gcType.equals(INHERITED)) {
      ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
      storeGC(new PersistentBean(gc));
      if (gcType.equals(LOCAL)) {
        dataset.getLocalMetadata().setGeospatialCoverage(gc);
        dataset.getLocalMetadataInheritable().setGeospatialCoverage(null);

      } else {
        dataset.getLocalMetadata().setGeospatialCoverage(null);
        dataset.getLocalMetadataInheritable().setGeospatialCoverage(gc);
      }
    }

    String tcType = (String) metadataPP.getFieldValue(TC_TYPE);
    if (!tcType.equals(INHERITED)) {
      DateRange dateRange = dateRangeSelector.getDateRange();
      if (tcType.equals(LOCAL)) {
        dataset.getLocalMetadata().setTimeCoverage(dateRange);
        dataset.getLocalMetadataInheritable().setTimeCoverage((DateRange) null);

      } else {
        dataset.getLocalMetadata().setTimeCoverage((DateRange) null);
        dataset.getLocalMetadataInheritable().setTimeCoverage(dateRange);
      }
    }

    setStoreValue(SUMMARY, persBean, true);
    setStoreValue(RIGHTS, persBean, true);
    setStoreValue(HISTORY, persBean, true);
    setStoreValue(PROCESSING, persBean, true);

    // storeBeanList( variablesFld, VARIABLES, persBean);
    storeBeanList(creatorsFld, CREATORS, persBean);
    storeBeanList(publishersFld, PUBLISHERS, persBean);
    storeBeanList(projectsFld, PROJECTS, persBean);
    storeBeanList(keywordsFld, KEYWORDS, persBean);
    storeBeanList(datesFld, DATES, persBean);
    storeBeanList(contributorsFld, CONTRIBUTORS, persBean);
    storeBeanList(docsFld, DOCUMENTATION, persBean);

    if (dataset instanceof InvDatasetScan) {
      setStoreValue(dscanPP, DSCAN_PATH, persBean, false);
      setStoreValue(dscanPP, DSCAN_DIR, persBean, false);
      // setStoreValue( dscanPP, DSCAN_FILTER, persBean, false);
      setStoreValue(dscanPP, DSCAN_ADDSIZE, persBean, false);
      // setStoreValue( dscanPP, DSCAN_ADDLATEST, persBean, false);
      // setStoreValue( dscanPP, DSCAN_TC_MATCH, persBean, false);
      // setStoreValue( dscanPP, DSCAN_TC_SUBS, persBean, false);
      // setStoreValue( dscanPP, DSCAN_TC_DURATOPN, persBean, false);
    }

    dataset.finish();
  }
Exemplo n.º 5
0
  public boolean setDataset(InvDatasetImpl ds) {
    if (!accept()) return false;

    this.dataset = ds;
    this.leafDataset = null;
    exampleButton.setText("Example Dataset");

    //////////
    PersistentBean persBean = new PersistentBean(ds);

    setEditValue(NAME, persBean, 0);
    setEditValue(ID, persBean, 0);

    setEditValueWithInheritence(AUTHORITY, persBean);
    setEditValueWithInheritence(SERVICE_NAME, persBean);

    setEditValueWithInheritence(FORMAT_TYPE, persBean);
    setEditValueWithInheritence(DATA_TYPE, persBean);

    setEditValue(COLLECTION_TYPE, persBean, 0);
    setEditValue(HARVEST, persBean, 0);

    // gotta find which GeospatialCoverage to use.
    int mode = 0;
    ThreddsMetadata.GeospatialCoverage gc = ds.getLocalMetadata().getGeospatialCoverage();
    if ((gc == null) || gc.isEmpty()) {
      gc = ds.getLocalMetadataInheritable().getGeospatialCoverage();
      mode = 1;
    }
    if ((gc == null) || gc.isEmpty()) {
      gc = ds.getGeospatialCoverage();
      mode = 2; // inherited
    }
    metadataPP.setFieldValue(GC_TYPE, inherit_types.get(mode));
    setGC(gc, mode);

    // gotta find which TimeCoverage to use.
    mode = 0;
    CalendarDateRange tc = ds.getLocalMetadata().getCalendarDateCoverage();
    if (tc == null) {
      tc = ds.getLocalMetadataInheritable().getCalendarDateCoverage();
      mode = 1;
    }
    if (tc == null) {
      tc = ds.getCalendarDateCoverage();
      mode = 2; // inherited
    }
    metadataPP.setFieldValue(TC_TYPE, inherit_types.get(mode));
    if (tc != null) dateRangeSelector.setDateRange(tc.toDateRange());
    setTCmode(mode);

    setEditValueWithInheritence(SUMMARY, persBean);
    setEditValueWithInheritence(RIGHTS, persBean);
    setEditValueWithInheritence(HISTORY, persBean);
    setEditValueWithInheritence(PROCESSING, persBean);

    setVariables(variablesFld);
    setBeanList(creatorsFld, CREATORS, persBean);
    setBeanList(publishersFld, PUBLISHERS, persBean);
    setBeanList(projectsFld, PROJECTS, persBean);
    setBeanList(keywordsFld, KEYWORDS, persBean);
    setBeanList(datesFld, DATES, persBean);
    setBeanList(contributorsFld, CONTRIBUTORS, persBean);
    setBeanList(docsFld, DOCUMENTATION, persBean);

    if (ds instanceof InvDatasetScan) {
      dscanPP.setEnabled(true);
      setEditValue(dscanPP, DSCAN_PATH, persBean, 0);
      setEditValue(dscanPP, DSCAN_DIR, persBean, 0);
      // setEditValue( dscanPP, DSCAN_FILTER, persBean, 0);
      setEditValue(dscanPP, DSCAN_ADDSIZE, persBean, 0);
      // setEditValue( dscanPP, DSCAN_ADDLATEST, persBean, 0);
      // setEditValue( dscanPP, DSCAN_TC_MATCH, persBean, 0);
      // setEditValue( dscanPP, DSCAN_TC_SUBS, persBean, 0);
      // setEditValue( dscanPP, DSCAN_TC_DURATOPN, persBean, 0);
    } else dscanPP.setEnabled(false);

    return true;
  }