}
});
CONSTRUCTOR_BUILDERS.put(Description.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String text = readString("the description text [testDescription]");
SecurityAttributes attr = buildSecurityAttributes("description");
return (new Description(text, attr));
}
});
CONSTRUCTOR_BUILDERS.put(Dates.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String created = readString("the created date [2010]");
String posted = readString("the posted date [2010]");
String validTil = readString("the validTil date [2010]");
String infoCutOff = readString("the infoCutOff date [2010]");
String approvedOn = readString("the approvedOn date [2010]");
String receivedOn = readString("the receivedOn date [2010]");
return (new Dates(null, created, posted, validTil, infoCutOff, approvedOn, receivedOn));
}
});
CONSTRUCTOR_BUILDERS.put(AbstractProducerRole.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
DDMSVersion version = DDMSVersion.getCurrentVersion();
String producerType = readString("the producer type [creator]");
String entityType = readString("the entity type [organization]");
String pocTypes = readString("the pocType [DoD-Dist-B]");
SecurityAttributes attr = buildSecurityAttributes("producer");
IRoleEntity entity = null;
if (Person.getName(version).equals(entityType))
entity = (Person) inputLoop(Person.class);
else if (Organization.getName(version).equals(entityType))
entity = (Organization) inputLoop(Organization.class);
else if (Service.getName(version).equals(entityType))
entity = (Service) inputLoop(Service.class);
else if (Unknown.getName(version).equals(entityType))
entity = (Unknown) inputLoop(Unknown.class);
if (Creator.getName(version).equals(producerType))
return (new Creator(entity, null, attr));
if (Contributor.getName(version).equals(producerType))
return (new Creator(entity, null, attr));
if (Publisher.getName(version).equals(producerType))
return (new Publisher(entity, null, attr));
if (PointOfContact.getName(version).equals(producerType))
return (new PointOfContact(entity, Util.getXsListAsList(pocTypes), attr));
throw new InvalidDDMSException("Unknown producerType: " + producerType);
}
});
CONSTRUCTOR_BUILDERS.put(Person.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
int numNames = readInt("the number of names this person has [1]");
if (numNames == 0) {
println("At least 1 name is required. Defaulting to 1 name.");
numNames = 1;
}
int numPhones = readInt("the number of phone numbers this person has [0]");
int numEmails = readInt("the number of email addresses this person has [0]");
List<String> names = new ArrayList<String>();
for (int i = 0; i < numNames; i++) {
names.add(readString("entity name #" + (i + 1) + " [testName" + (i + 1) + "]"));
}
List<String> phones = new ArrayList<String>();
for (int i = 0; i < numPhones; i++) {
phones.add(readString("entity phone number #" + (i + 1) + " [testPhone" + (i + 1) + "]"));
}
List<String> emails = new ArrayList<String>();
for (int i = 0; i < numEmails; i++) {
emails.add(readString("entity email #" + (i + 1) + " [testEmail" + (i + 1) + "]"));
}
String surname = readString("the person surname [testSurname]");
String userID = readString("the person userID [testID]");
String affiliation = readString("the person affiliation [testOrg]");
// Skip optional extensible attributes.
return (new Person(names, surname, phones, emails, userID, Util.getXsListAsList(affiliation)));
}
});
CONSTRUCTOR_BUILDERS.put(Organization.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
int numNames = readInt("the number of names this organization has [1]");
if (numNames == 0) {
println("At least 1 name is required. Defaulting to 1 name.");
numNames = 1;
}
int numPhones = readInt("the number of phone numbers this organization has [0]");
int numEmails = readInt("the number of email addresses this organization has [0]");
int numSubs = readInt("the number of suborganizations to include [0]");
List<String> names = new ArrayList<String>();
for (int i = 0; i < numNames; i++) {
names.add(readString("entity name #" + (i + 1) + " [testName" + (i + 1) + "]"));
}
List<String> phones = new ArrayList<String>();
for (int i = 0; i < numPhones; i++) {
phones.add(readString("entity phone number #" + (i + 1) + " [testPhone" + (i + 1) + "]"));
}
List<String> emails = new ArrayList<String>();
for (int i = 0; i < numEmails; i++) {
emails.add(readString("entity email #" + (i + 1) + " [testEmail" + (i + 1) + "]"));
}
List<SubOrganization> subOrgs = new ArrayList<SubOrganization>();
for (int i = 0; i < numSubs; i++) {
println("* SubOrganization #" + (i + 1));
subOrgs.add((SubOrganization) inputLoop(SubOrganization.class));
}
String acronym = readString("the Organization acronym [testAcronym]");
// Skip optional extensible attributes.
return (new Organization(names, phones, emails, subOrgs, acronym));
}
});
CONSTRUCTOR_BUILDERS.put(SubOrganization.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String value = readString("the value [testSubOrganization]");
SecurityAttributes attr = buildSecurityAttributes("suborganization");
return (new SubOrganization(value, attr));
}
});
CONSTRUCTOR_BUILDERS.put(Service.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
int numNames = readInt("the number of names this service has [1]");
if (numNames == 0) {
println("At least 1 name is required. Defaulting to 1 name.");
numNames = 1;
}
int numPhones = readInt("the number of phone numbers this service has [0]");
int numEmails = readInt("the number of email addresses this service has [0]");
List<String> names = new ArrayList<String>();
for (int i = 0; i < numNames; i++) {
names.add(readString("entity name #" + (i + 1) + " [testName" + (i + 1) + "]"));
}
List<String> phones = new ArrayList<String>();
for (int i = 0; i < numPhones; i++) {
phones.add(readString("entity phone number #" + (i + 1) + " [testPhone" + (i + 1) + "]"));
}
List<String> emails = new ArrayList<String>();
for (int i = 0; i < numEmails; i++) {
emails.add(readString("entity email #" + (i + 1) + " [testEmail" + (i + 1) + "]"));
}
// Skip optional extensible attributes.
return (new Service(names, phones, emails));
}
});
CONSTRUCTOR_BUILDERS.put(Unknown.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
int numNames = readInt("the number of names this unknown entity has [1]");
if (numNames == 0) {
println("At least 1 name is required. Defaulting to 1 name.");
numNames = 1;
}
int numPhones = readInt("the number of phone numbers this unknown entity has [0]");
int numEmails = readInt("the number of email addresses this unknown entity has [0]");
List<String> names = new ArrayList<String>();
for (int i = 0; i < numNames; i++) {
names.add(readString("entity name #" + (i + 1) + " [testName" + (i + 1) + "]"));
}
List<String> phones = new ArrayList<String>();
for (int i = 0; i < numPhones; i++) {
phones.add(readString("entity phone number #" + (i + 1) + " [testPhone" + (i + 1) + "]"));
}
List<String> emails = new ArrayList<String>();
for (int i = 0; i < numEmails; i++) {
emails.add(readString("entity email #" + (i + 1) + " [testEmail" + (i + 1) + "]"));
}
// Skip optional extensible attributes.
return (new Unknown(names, phones, emails));
}
});
CONSTRUCTOR_BUILDERS.put(Keyword.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String keyword = readString("the keyword value [testValue]");
SecurityAttributes attr = buildSecurityAttributes("keyword");
// Skip optional extensible attributes.
return (new Keyword(keyword, attr));
}
});
CONSTRUCTOR_BUILDERS.put(Category.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String qualifier = readString("the qualifier [testQualifier]");
String code = readString("the code [testCode]");
String label = readString("the label [testLabel]");
// Skip optional extensible attributes.
return (new Category(qualifier, code, label, buildSecurityAttributes("category")));
}
});
CONSTRUCTOR_BUILDERS.put(ProductionMetric.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String subject = readString("the subject [testSubject]");
String coverage = readString("the coverage [testCoverage]");
return (new ProductionMetric(subject, coverage, buildSecurityAttributes("productionMetric")));
}
});
CONSTRUCTOR_BUILDERS.put(NonStateActor.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {
String value = readString("the value [testValue]");
int order = readInt("the order [1]");
String qualifier = readString("the qualifier [testQualifier]");
SecurityAttributes attr = buildSecurityAttributes("nonStateActor");
return (new NonStateActor(value, Integer.valueOf(order), qualifier, attr));
}
});
CONSTRUCTOR_BUILDERS.put(SubjectCoverage.class, new IConstructorBuilder() {
public IDDMSComponent build() throws IOException, InvalidDDMSException {