Search in sources :

Example 1 with EccInformation

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;
}
Also used : SW360Utils.newDefaultEccInformation(org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation)

Example 2 with EccInformation

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;
}
Also used : EccInformation(org.eclipse.sw360.datahandler.thrift.components.EccInformation) SW360Utils.newDefaultEccInformation(org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation)

Example 3 with EccInformation

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;
}
Also used : SW360Utils.newDefaultEccInformation(org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation)

Example 4 with 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));
}
Also used : SW360Utils.newDefaultEccInformation(org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation) Test(org.junit.Test)

Example 5 with 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);
}
Also used : DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) ComponentDatabaseHandler(org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Aggregations

SW360Utils.newDefaultEccInformation (org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation)5 EccInformation (org.eclipse.sw360.datahandler.thrift.components.EccInformation)3 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)1 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)1 ComponentDatabaseHandler (org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler)1 ProjectReleaseRelationship (org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship)1 Release (org.eclipse.sw360.datahandler.thrift.components.Release)1 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)1 ProjectRelationship (org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)1 User (org.eclipse.sw360.datahandler.thrift.users.User)1 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)1 Before (org.junit.Before)1 Test (org.junit.Test)1