Exemplo n.º 1
0
  // Print <Cluster>-prototype-ini.dat file
  // File format:
  // [Prototype] CombatOrganization|CivilanOrganization
  // [UniqueId] "UTC/CombatOrg"
  // [UIC] "UIC/<OrganizationName>
  // [Relationship]
  // Superior  <Superior> ""
  // Support   <Supported> <Role>
  // [TypeIdentificationPG]
  // TypeIdentification String "UTC/RTOrg"
  // Nomenclature String <Nomenclature>
  // AlternateTypeIdentification String "SRC/<SRC>"
  // [ClusterPG]
  // MessageAddress String <OrganizationName>
  // [OrganizationPG]
  // Roles Collection<Role> <Role>
  // [MilitaryOrgPG]
  // UIC String <UIC>
  // Echelon String <Echelon>
  // UTC String <UTC>
  // SRC String <SRC>
  //
  private void dumpOrganizationInfo(Hashtable all_organizations, String path) throws IOException {

    Hashtable supportedOrgRoles = null;

    for (Enumeration e = all_organizations.keys(); e.hasMoreElements(); ) {
      supportedOrgRoles = new Hashtable();
      String org_name = (String) e.nextElement();
      OrganizationData org_data = (OrganizationData) all_organizations.get(org_name);
      PrintWriter org_file;

      try {
        if (path != null) {
          org_file = createPrintWriter(path + File.separator + org_name + "-prototype-ini.dat");
        } else {
          org_file = createPrintWriter(org_name + "-prototype-ini.dat");
        }
        org_file.println(
            "[Prototype] "
                + (org_data.isCivilan() ? "CivilianOrganization" : "MilitaryOrganization"));
        org_file.println("\n[UniqueId] " + '"' + "UTC/CombatOrg" + '"');
        org_file.println("\n[UIC] " + '"' + "UIC/" + org_name + '"');

        // Write out Superior/Support Relationships
        org_file.println("\n[Relationship]");
        if (org_data.mySuperior != null) {
          org_file.println("Superior " + '"' + org_data.mySuperior + '"' + " " + '"' + '"');
        }

        for (Enumeration rels = org_data.mySupportRelations.elements(); rels.hasMoreElements(); ) {
          SupportRelation suprel = (SupportRelation) rels.nextElement();

          if (!supportedOrgRoles.containsKey(suprel.mySupportedOrganization)) {
            supportedOrgRoles.put(suprel.mySupportedOrganization, suprel.myRole);
          } else {
            String role = (String) supportedOrgRoles.get(suprel.mySupportedOrganization);
            role = role + ", " + suprel.myRole;
            supportedOrgRoles.put(suprel.mySupportedOrganization, role);
          }
        }

        for (Enumeration roles = supportedOrgRoles.keys(); roles.hasMoreElements(); ) {
          String supportedOrg = (String) roles.nextElement();
          String role = (String) supportedOrgRoles.get(supportedOrg);
          org_file.println("Supporting " + '"' + supportedOrg + '"' + " " + '"' + role + '"');
        }

        // Print TypeIdentificationPG fields
        org_file.println("\n[TypeIdentificationPG]");
        org_file.println("TypeIdentification String " + '"' + "UTC/RTOrg" + '"');
        org_file.println("Nomenclature String " + '"' + org_data.myNomenclature + '"');
        org_file.println(
            "AlternateTypeIdentification String " + '"' + "SRC/" + org_data.mySRC + '"');

        // Print ClusterPG info
        org_file.println("\n[ClusterPG]");
        org_file.println("MessageAddress String " + '"' + org_name + '"');

        // Print OrganizationPG (Roles) info
        org_file.println("\n[OrganizationPG]");
        org_file.print("Roles Collection<Role> " + '"');
        boolean is_first = true;
        for (Enumeration roles = org_data.myRoles.elements(); roles.hasMoreElements(); ) {
          String role = (String) roles.nextElement();
          if (!is_first) {
            org_file.print(", ");
          }
          org_file.print(role);
          is_first = false;
        }
        org_file.println('"');

        // Print MilitaryOrgPG info
        org_file.println("\n[MilitaryOrgPG]");
        org_file.println("UIC String " + '"' + org_data.myUIC + '"');
        if (org_data.myEchelon.intValue() != -1) {
          org_file.println("Echelon String " + '"' + org_data.myEchelon.intValue() + '"');
        } else {
          org_file.println("Echelon String " + '"' + '"');
        }
        org_file.println("UTC String " + '"' + org_data.myUTC + '"');
        org_file.println("SRC String " + '"' + org_data.mySRC + '"');
        if (org_data.myIsReserve == true) {
          org_file.println("IsReserve       boolean     true");
        } else {
          org_file.println("IsReserve       boolean     false");
        }

        // Print HomeLocationPG info under Military Org PG
        org_file.println(
            "HomeLocation     GeolocLocation   "
                + "\"GeolocCode="
                + org_data.myHomeGeoLoc
                + ", InstallationTypeCode="
                + org_data.myHomeInstallCode
                + ", CountryStateCode="
                + org_data.myHomeCSCode
                + ", CountryStateName="
                + org_data.myHomeCSName
                + ", IcaoCode="
                + org_data.myHomeICAOCode
                + ", Name="
                + org_data.myHomeLocation
                + ", Latitude=Latitude "
                + org_data.myHomeLatitude
                + "degrees, Longitude=Longitude "
                + org_data.myHomeLongitude
                + "degrees\"");

        /*
        // Print AssignmentPG info
        org_file.println("\n[AssignmentPG]");
        org_file.println("GeolocCode            String    "+'"'+org_data.myAssignedGeoLoc+'"');
        org_file.println("InstallationTypeCode  String    "+'"'+org_data.myAssignedInstallCode+'"');
        org_file.println("CountryStateCode      String    "+'"'+org_data.myAssignedCSCode+'"');
        org_file.println("CountryStateName      String    "+'"'+org_data.myAssignedCSName+'"');
        org_file.println("IcaoCode              String    "+'"'+org_data.myAssignedICAOCode+'"');
        */
        // Print CSSCapabilities info
        if (org_data.myCSSCapabilities != null) {
          is_first = true;
          org_file.println("\n[CSSCapabilityPG]");
          org_file.print("Capabilities Collection<CSSCapability> " + '"');
          for (Enumeration eCap = org_data.myCSSCapabilities.elements(); eCap.hasMoreElements(); ) {
            CSSCapabilities cssCap = (CSSCapabilities) eCap.nextElement();
            if (!is_first) {
              org_file.print(", ");
            }
            org_file.print(cssCap.capability);
            org_file.print(" " + cssCap.qty);
            if (!cssCap.period.equals("")) {
              org_file.print(" Duration=" + cssCap.period);
            }
            is_first = false;
          }
          org_file.println('"');
        }

        org_file.close();
      } catch (IOException exc) {
        System.out.println("IOException:  " + exc);
        System.exit(-1);
      }
    }
  }