Search in sources :

Example 1 with COTSDetails

use of org.eclipse.sw360.datahandler.thrift.components.COTSDetails in project sw360portal by sw360.

the class DisplayReleaseChanges method renderCOTSDetails.

private String renderCOTSDetails() {
    if (!ensureSomethingTodoAndNoNull(Release._Fields.COTS_DETAILS)) {
        return "";
    }
    StringBuilder display = new StringBuilder();
    if (!actual.isSet(Release._Fields.COTS_DETAILS)) {
        actual.cotsDetails = new COTSDetails();
    }
    for (COTSDetails._Fields field : COTSDetails._Fields.values()) {
        FieldMetaData fieldMetaData = COTSDetails.metaDataMap.get(field);
        displaySimpleFieldOrSet(display, actual.getCotsDetails(), additions.getCotsDetails(), deletions.getCotsDetails(), field, fieldMetaData, "");
    }
    return "<h3> Changes in COTS Details </h3>" + String.format("<table class=\"%s\" id=\"%schanges\" >", tableClasses, idPrefix) + String.format("<thead><tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL) + display.toString() + "</tbody></table>";
}
Also used : FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) COTSDetails(org.eclipse.sw360.datahandler.thrift.components.COTSDetails)

Example 2 with COTSDetails

use of org.eclipse.sw360.datahandler.thrift.components.COTSDetails in project sw360portal by sw360.

the class COTSDetailsModerationRequestGenerator method setAdditionsAndDeletions.

@Override
public ModerationRequest setAdditionsAndDeletions(ModerationRequest request, COTSDetails update, COTSDetails actual) {
    updateDocument = update == null ? new COTSDetails() : update;
    actualDocument = actual == null ? new COTSDetails() : actual;
    documentAdditions = null;
    documentDeletions = null;
    for (COTSDetails._Fields field : COTSDetails._Fields.values()) {
        if (COTSDetails.metaDataMap.get(field).valueMetaData.type == TType.BOOL || COTSDetails.metaDataMap.get(field).valueMetaData.type == TType.I32) {
            if (actualDocument.getFieldValue(field) != updateDocument.getFieldValue(field)) {
                if (documentAdditions == null) {
                    documentAdditions = new COTSDetails();
                }
                if (documentDeletions == null) {
                    documentDeletions = new COTSDetails();
                }
                documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
                documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
            }
            continue;
        }
        if (COTSDetails.metaDataMap.get(field).valueMetaData.type == TType.STRING) {
            if (isNullOrEmpty((String) actualDocument.getFieldValue(field)) && isNullOrEmpty((String) updateDocument.getFieldValue(field))) {
                continue;
            }
            if (actualDocument.isSet(field) && !updateDocument.isSet(field)) {
                if (documentDeletions == null) {
                    documentDeletions = new COTSDetails();
                }
                documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
                continue;
            }
            if (updateDocument.isSet(field) && !actualDocument.isSet(field)) {
                if (documentAdditions == null) {
                    documentAdditions = new COTSDetails();
                }
                documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
                continue;
            }
            if (!(actualDocument.getFieldValue(field).equals(updateDocument.getFieldValue(field)))) {
                if (documentAdditions == null) {
                    documentAdditions = new COTSDetails();
                }
                if (documentDeletions == null) {
                    documentDeletions = new COTSDetails();
                }
                documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
                documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
            }
        }
    }
    request.getReleaseAdditions().setCotsDetails(documentAdditions);
    request.getReleaseDeletions().setCotsDetails(documentDeletions);
    return request;
}
Also used : COTSDetails(org.eclipse.sw360.datahandler.thrift.components.COTSDetails)

Aggregations

COTSDetails (org.eclipse.sw360.datahandler.thrift.components.COTSDetails)2 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)1