public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof WSIBox) { value = ((WSIBox) value).getTitle(); } if (value instanceof TridasMeasurementSeries) { TridasMeasurementSeries ms = (TridasMeasurementSeries) value; TridasGenericField f = GenericFieldUtils.findField(ms, "tellervo.internal.labcodeText"); value = (f != null) ? f.getValue() : ms.getTitle(); } if (value instanceof TridasRadius) { TridasRadius r = (TridasRadius) value; TridasGenericField f = GenericFieldUtils.findField(r, "tellervo.internal.labcodeText"); value = (f != null) ? f.getValue() : r.getTitle(); } if (value instanceof TridasSample) { TridasSample s = (TridasSample) value; LabCode labcode = new LabCode(); boolean set = false; if (GenericFieldUtils.findField(s, "tellervo.objectLabCode") != null) { labcode.appendSiteCode(GenericFieldUtils.findField(s, "tellervo.objectLabCode").getValue()); if (GenericFieldUtils.findField(s, "tellervo.elementLabCode") != null) { labcode.setElementCode( GenericFieldUtils.findField(s, "tellervo.elementLabCode").getValue()); labcode.setSampleCode(s.getTitle()); set = true; } } if (set) { value = LabCodeFormatter.getRadiusPrefixFormatter().format(labcode); } else { TridasGenericField f = GenericFieldUtils.findField(s, "tellervo.internal.labcodeText"); value = (f != null) ? f.getValue() : s.getTitle(); } } if (value instanceof TridasElement) { TridasElement e = (TridasElement) value; TridasGenericField f = GenericFieldUtils.findField(e, "tellervo.internal.labcodeText"); value = (f != null) ? f.getValue() : e.getTitle(); } /*else { System.out.println("The object type "+ value.getClass().toString()+" is unsupported in TridasListCellRenderer"); }*/ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); }
/* (non-Javadoc) * @see org.tellervo.desktop.sample.CorinaMetadata#getWoodCompleteness() */ @Override public final TridasWoodCompleteness getWoodCompleteness() { if (series instanceof TridasMeasurementSeries) { TridasMeasurementSeries mseries = (TridasMeasurementSeries) series; // check for woodcompleteness here, return it if (mseries.isSetWoodCompleteness()) return mseries.getWoodCompleteness(); } // get the woodCompleteness from the radius, if it exists return have(radius) ? radius.getWoodCompleteness() : null; }
@SuppressWarnings("unchecked") @Override protected void parseFile(String[] argFileString, IMetadataFieldSet argDefaultFields) throws InvalidDendroFileException { defaults = (TrimsToTridasDefaults) argDefaultFields; // TODO run the 'metadata' through the defaults, as // the user may have specified his own metadata // Extract 'metadata' ;-) String userid = argFileString[0].trim(); SafeIntYear startYear = null; try { startYear = new SafeIntYear(argFileString[2].trim()); } catch (NumberFormatException e) { } // Extract data ArrayList<TridasValue> ringWidthValues = new ArrayList<TridasValue>(); for (int i = 3; i < argFileString.length; i++) { TridasValue v = new TridasValue(); if (argFileString[i].startsWith(" ")) { if (argFileString[i].trim().equals("999")) { break; } v.setValue(argFileString[i].trim()); ringWidthValues.add(v); log.debug("value = " + String.valueOf(argFileString[i])); } else { throw new InvalidDendroFileException(I18n.getText("trims.expectingSpace"), i); } } // Now build up our measurementSeries TridasMeasurementSeries series = defaults.getMeasurementSeriesWithDefaults(); TridasUnit units = new TridasUnit(); // Set units to 1/100th mm. Is this always the case? units.setNormalTridas(NormalTridasUnit.HUNDREDTH_MM); // Build identifier for series TridasIdentifier seriesId = new ObjectFactory().createTridasIdentifier(); seriesId.setValue(UUID.randomUUID().toString()); seriesId.setDomain( defaults.getDefaultValue(TridasMandatoryField.IDENTIFIER_DOMAIN).getStringValue()); // Build interpretation group for series TridasInterpretation interp = new TridasInterpretation(); interp.setFirstYear(startYear.toTridasYear(DatingSuffix.AD)); interp.setLastYear(startYear.add(ringWidthValues.size() - 1).toTridasYear(DatingSuffix.AD)); // Add values to nested value(s) tags TridasValues valuesGroup = new TridasValues(); valuesGroup.setValues(ringWidthValues); valuesGroup.setUnit(units); GenericDefaultValue<TridasVariable> variable = (GenericDefaultValue<TridasVariable>) defaults.getDefaultValue(TridasMandatoryField.MEASUREMENTSERIES_VARIABLE); valuesGroup.setVariable(variable.getValue()); ArrayList<TridasValues> valuesGroupList = new ArrayList<TridasValues>(); valuesGroupList.add(valuesGroup); // Add all the data to the series series.setValues(valuesGroupList); series.setInterpretation(interp); series.setIdentifier(seriesId); series.setLastModifiedTimestamp(DateUtils.getTodaysDateTime()); series.setDendrochronologist(userid); // Add series to our list mseriesList.add(series); }