use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentImportUtils method writeReleaseLinksToDatabase.
public static RequestSummary writeReleaseLinksToDatabase(FluentIterable<ReleaseLinkCSVRecord> csvRecords, ComponentService.Iface componentClient, User user) throws TException {
final List<Component> componentDetailedSummaryForExport = componentClient.getComponentDetailedSummaryForExport();
final Map<String, Release> releasesByIdentifier = getReleasesByIdentifier(componentDetailedSummaryForExport);
final Set<String> releasesIdentifiersToBeUpdated = new HashSet<>();
for (ReleaseLinkCSVRecord csvRecord : csvRecords) {
final String releaseIdentifier = csvRecord.getReleaseIdentifier();
final String linkedReleaseIdentifier = csvRecord.getLinkedReleaseIdentifier();
final ReleaseRelationship relationship = csvRecord.getRelationship();
if (releaseIdentifier != null && linkedReleaseIdentifier != null && relationship != null) {
final Release release = releasesByIdentifier.get(releaseIdentifier);
final Release linkedRelease = releasesByIdentifier.get(linkedReleaseIdentifier);
if (release != null && linkedRelease != null) {
final Map<String, ReleaseRelationship> releaseIdToRelationship = getRelationshipMap(release);
releaseIdToRelationship.put(linkedRelease.getId(), relationship);
release.setReleaseIdToRelationship(releaseIdToRelationship);
releasesIdentifiersToBeUpdated.add(releaseIdentifier);
}
}
}
final HashSet<Release> updatedReleases = getUpdatedReleases(releasesByIdentifier, releasesIdentifiersToBeUpdated);
return componentClient.updateReleases(updatedReleases, user);
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentAttachmentCSVRecordBuilderTest method testFillComponent.
@Test
public void testFillComponent() throws Exception {
final String componentName = "myCompo";
final Component component = new Component();
component.setName(componentName);
final ComponentAttachmentCSVRecordBuilder componentAttachmentCSVRecordBuilder = new ComponentAttachmentCSVRecordBuilder();
componentAttachmentCSVRecordBuilder.fill(component);
final ComponentAttachmentCSVRecord filledRecord = componentAttachmentCSVRecordBuilder.build();
assertThat(filledRecord.getComponentName(), is(componentName));
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ReleaseLinkCSVRecordBuilderTest method testFillComponent.
@Test
public void testFillComponent() throws Exception {
final String componentName = "myCompo";
final Component component = new Component();
component.setName(componentName);
final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
releaseLinkCSVRecordBuilder.fill(component);
final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
assertThat(filledRecord.getComponentName(), is(componentName));
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class DisplayComponentChanges method doStartTag.
public int doStartTag() throws JspException {
JspWriter jspWriter = pageContext.getOut();
StringBuilder display = new StringBuilder();
String namespace = getNamespace();
if (additions == null || deletions == null) {
return SKIP_BODY;
}
try {
for (Component._Fields field : Component._Fields.values()) {
switch(field) {
// ignored Fields
case ID:
case REVISION:
case TYPE:
case CREATED_BY:
case CREATED_ON:
case PERMISSIONS:
case DOCUMENT_STATE:
// Releases and aggregates:
case RELEASES:
case RELEASE_IDS:
case MAIN_LICENSE_IDS:
case LANGUAGES:
case OPERATING_SYSTEMS:
case VENDOR_NAMES:
// Taken care of externally
case ATTACHMENTS:
break;
default:
FieldMetaData fieldMetaData = Component.metaDataMap.get(field);
displaySimpleFieldOrSet(display, actual, additions, deletions, field, fieldMetaData, "");
}
}
String renderString = display.toString();
if (Strings.isNullOrEmpty(renderString)) {
renderString = "<h4> No changes in basic fields </h4>";
} else {
renderString = String.format("<table class=\"%s\" id=\"%schanges\" >", tableClasses, idPrefix) + "<thead><tr><th colspan=\"4\"> Changes for Basic fields</th></tr>" + String.format("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL) + renderString + "</tbody></table>";
}
jspWriter.print(renderString);
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ReleaseLinkCSVRecordBuilderTest method testFillLinkedComponent.
@Test
public void testFillLinkedComponent() throws Exception {
final String componentName = "myCompo";
final Component component = new Component();
component.setName(componentName);
final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
releaseLinkCSVRecordBuilder.fillLinking(component);
final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
assertThat(filledRecord.getLinkedComponentName(), is(componentName));
}
Aggregations