Exemple #1
0
  private CrossSectionPart commitPart(
      final Session session,
      final String dbType,
      final CrossSection crossSection,
      final GafPart part,
      final PDBNameGenerator nameGenerator)
      throws Exception {
    final CrossSectionPart csPart = new CrossSectionPart();

    final GafKind partKind = part.getKind();

    final String name = nameGenerator.createUniqueName(partKind.toString());

    csPart.setName(name);

    if (part.getKind() == GafKind.W) {
      final String gafFileName = m_profiles.getGafFilename();
      csPart.setDescription(
          String.format(Messages.getString("Gaf2Db.5"), gafFileName)); // $NON-NLS-1$
    } else csPart.setDescription(StringUtils.EMPTY);

    final CrossSectionPartType partType = findPartType(partKind);
    csPart.setCrossSectionPartType(partType);

    final Geometry line = part.getLine(dbType);
    csPart.setLine(line);

    csPart.setCrossSection(crossSection);
    session.save(csPart);
    return csPart;
  }
Exemple #2
0
  private CrossSectionPartType findPartType(final GafKind partKind) {
    for (final CrossSectionPartType type : m_knownTypes) {
      if (type.getCategory().equals(partKind.toString())) return type;
    }

    throw new IllegalArgumentException(
        String.format("Unknown part category: %s", partKind)); // $NON-NLS-1$
  }