use of org.eclipse.sw360.datahandler.thrift.components.EccInformation in project sw360portal by sw360.
the class ReleaseModerator method updateEccInformation.
private Release updateEccInformation(Release release, Release releaseAdditions) {
EccInformation actual = release.getEccInformation();
EccInformation additions = releaseAdditions.getEccInformation();
if (additions == null) {
return release;
}
if (actual == null) {
actual = newDefaultEccInformation();
}
for (EccInformation._Fields field : EccInformation._Fields.values()) {
if (additions.isSet(field)) {
actual.setFieldValue(field, additions.getFieldValue(field));
}
}
release.setEccInformation(actual);
return release;
}
use of org.eclipse.sw360.datahandler.thrift.components.EccInformation in project sw360portal by sw360.
the class ThriftValidate method ensureEccInformationIsSet.
public static Release ensureEccInformationIsSet(Release release) {
EccInformation eccInformation = release.isSetEccInformation() ? release.getEccInformation() : newDefaultEccInformation();
if (!eccInformation.isSetEccStatus()) {
eccInformation.setEccStatus(ECCStatus.OPEN);
}
release.setEccInformation(eccInformation);
return release;
}
use of org.eclipse.sw360.datahandler.thrift.components.EccInformation in project sw360portal by sw360.
the class ComponentCSVRecord method getEccInformation.
public EccInformation getEccInformation() {
EccInformation eccInformation = newDefaultEccInformation();
if (!isNullOrEmpty(eccStatus)) {
final ECCStatus eccs = ThriftEnumUtils.stringToEnum(eccStatus, ECCStatus.class);
eccInformation.setEccStatus(eccs);
}
if (!isNullOrEmpty(eccAL)) {
eccInformation.setAL(eccAL);
}
if (!isNullOrEmpty(eccECCN)) {
eccInformation.setECCN(eccECCN);
}
if (!isNullOrEmpty(eccMaterialIndexNumber)) {
eccInformation.setMaterialIndexNumber(eccMaterialIndexNumber);
}
if (!isNullOrEmpty(eccComment)) {
eccInformation.setEccComment(eccComment);
}
if (!isNullOrEmpty(eccAssessorContactPerson)) {
eccInformation.setAssessorContactPerson(eccAssessorContactPerson);
}
if (!isNullOrEmpty(eccAssessorDepartment)) {
eccInformation.setAssessorDepartment(eccAssessorDepartment);
}
if (!isNullOrEmpty(eccAssessmentDate)) {
eccInformation.setAssessmentDate(eccAssessmentDate);
}
return eccInformation;
}
use of org.eclipse.sw360.datahandler.thrift.components.EccInformation in project sw360portal by sw360.
the class ComponentCSVRecordBuilderTest method testFillEccInfo.
@Test
public void testFillEccInfo() throws Exception {
final EccInformation eccInformation = newDefaultEccInformation();
eccInformation.setEccStatus(ECCStatus.APPROVED).setAL("AL").setECCN("ECCN").setMaterialIndexNumber("MIN").setEccComment("Comment").setAssessorContactPerson("JN").setAssessorDepartment("T").setAssessmentDate("date");
final ComponentCSVRecordBuilder componentCSVRecordBuilder = new ComponentCSVRecordBuilder().fill(eccInformation);
final ComponentCSVRecord build = componentCSVRecordBuilder.build();
assertThat(build.getEccInformation(), is(eccInformation));
}
use of org.eclipse.sw360.datahandler.thrift.components.EccInformation in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method setUp.
@Before
public void setUp() throws Exception {
assertTestString(dbName);
assertTestString(attachmentsDbName);
// Set up vendors
vendors = new HashMap<>();
vendors.put("V1", new Vendor().setId("V1").setShortname("Microsoft").setFullname("Microsoft Corporation").setUrl("http://www.microsoft.com"));
vendors.put("V2", new Vendor().setId("V2").setShortname("Apache").setFullname("The Apache Software Foundation").setUrl("http://www.apache.org"));
vendors.put("V3", new Vendor().setId("V3").setShortname("Oracle").setFullname("Oracle Corporation Inc").setUrl("http://www.oracle.com"));
components = new ArrayList<>();
Component component1 = new Component().setId("C1").setName("component1").setDescription("d1").setCreatedBy(email1).setMainLicenseIds(new HashSet<>(Arrays.asList("lic1"))).setCreatedOn("2017-07-20");
component1.addToReleaseIds("R1A");
component1.addToReleaseIds("R1B");
components.add(component1);
Component component2 = new Component().setId("C2").setName("component2").setDescription("d2").setCreatedBy(email2).setMainLicenseIds(new HashSet<>(Arrays.asList("lic2"))).setCreatedOn("2017-07-21");
component2.addToReleaseIds("R2A");
component2.addToReleaseIds("R2B");
component2.addToReleaseIds("R2C");
components.add(component2);
Component component3 = new Component().setId("C3").setName("component3").setDescription("d3").setCreatedBy(email1).setMainLicenseIds(new HashSet<>(Arrays.asList("lic3"))).setCreatedOn("2017-07-22");
component3.addToSubscribers(email1);
component3.addToLanguages("E");
components.add(component3);
releases = new ArrayList<>();
Release release1a = new Release().setId("R1A").setComponentId("C1").setName("component1").setVersion("releaseA").setCreatedBy(email1).setVendorId("V1");
releases.add(release1a);
Release release1b = new Release().setId("R1B").setComponentId("C1").setName("component1").setVersion("releaseB").setCreatedBy(email2).setVendorId("V2");
release1b.setEccInformation(new EccInformation().setAL("AL"));
release1b.addToSubscribers(email1);
releases.add(release1b);
Release release2a = new Release().setId("R2A").setComponentId("C2").setName("component2").setVersion("releaseA").setCreatedBy(email1).setVendorId("V3");
releases.add(release2a);
Release release2b = new Release().setId("R2B").setComponentId("C2").setName("component2").setVersion("releaseB").setCreatedBy(email2).setVendorId("V1");
releases.add(release2b);
release2b.addToSubscribers(email2);
Release release2c = new Release().setId("R2C").setComponentId("C2").setName("component2").setVersion("releaseC").setCreatedBy(email1).setVendorId("V2");
releases.add(release2c);
// Create the database
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), dbName);
// Prepare the database
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
for (Vendor vendor : vendors.values()) {
databaseConnector.add(vendor);
}
for (Component component : components) {
databaseConnector.add(component);
}
for (Release release : releases) {
databaseConnector.add(release);
}
componentMap = ThriftUtils.getIdMap(components);
releaseMap = ThriftUtils.getIdMap(releases);
// Prepare the handler
handler = new ComponentDatabaseHandler(DatabaseSettings.getConfiguredHttpClient(), dbName, attachmentsDbName, moderator, releaseModerator);
}
Aggregations