Search in sources :

Example 1 with ReferenceDocData

use of org.eclipse.sw360.datahandler.thrift.changelogs.ReferenceDocData in project sw360 by eclipse.

the class DatabaseHandlerUtil method referenceDocChanges.

/**
 * Register Reference Doc changes ad part of Parent Doc update
 */
private static <T extends TBase> void referenceDocChanges(T oldDocVersion, T newDocVersion, String userEdited, List<ChangeLogs> referenceDocLogList, AttachmentConnector attachmentConnector, ChangeLogs changeLogParent) {
    if (newDocVersion instanceof Project || newDocVersion instanceof Component || newDocVersion instanceof Release) {
        getChangeLogsForAttachments(oldDocVersion, newDocVersion, userEdited, referenceDocLogList, attachmentConnector);
    }
    Set<ReferenceDocData> referenceDocDataSet = new HashSet<ReferenceDocData>();
    referenceDocLogList.stream().forEach(refLog -> {
        ReferenceDocData refDocData = new ReferenceDocData();
        refDocData.setDbName(refLog.getDbName());
        refDocData.setRefDocId(refLog.getDocumentId());
        refDocData.setRefDocOperation(refLog.getOperation());
        refDocData.setRefDocType(refLog.getDocumentType());
        referenceDocDataSet.add(refDocData);
    });
    changeLogParent.setReferenceDoc(referenceDocDataSet);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ReferenceDocData(org.eclipse.sw360.datahandler.thrift.changelogs.ReferenceDocData) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with ReferenceDocData

use of org.eclipse.sw360.datahandler.thrift.changelogs.ReferenceDocData in project sw360 by eclipse.

the class ChangeLogSpecTest method before.

@Before
public void before() throws TException, IOException {
    ChangeLogs changeLog = new ChangeLogs();
    changeLog.setId("1234");
    changeLog.setDocumentId("4567");
    changeLog.setUserEdited("admin@sw360.org");
    changeLog.setChangeTimestamp("2021-01-08");
    changeLog.setOperation(Operation.UPDATE);
    changeLog.setDocumentType("project");
    HashSet<ChangedFields> changes = new HashSet<ChangedFields>();
    ChangedFields changedFields = new ChangedFields();
    changedFields.setFieldName("version");
    changedFields.setFieldValueOld("\"2\"");
    changedFields.setFieldValueNew("\"25\"");
    ChangedFields changedFields1 = new ChangedFields();
    changedFields1.setFieldName("name");
    changedFields1.setFieldValueOld("\"TestProj\"");
    changedFields1.setFieldValueNew("\"TestProject\"");
    changes.add(changedFields);
    changes.add(changedFields1);
    HashSet<ReferenceDocData> referenceDoc = new HashSet<ReferenceDocData>();
    ReferenceDocData referenceDocData = new ReferenceDocData();
    referenceDocData.setRefDocId("98765");
    referenceDocData.setRefDocOperation(Operation.CREATE);
    referenceDocData.setRefDocType("attachment");
    referenceDoc.add(referenceDocData);
    changeLog.setReferenceDoc(referenceDoc);
    changeLog.setChanges(changes);
    ChangeLogs changeLog2 = new ChangeLogs();
    changeLog2.setId("2345");
    changeLog2.setDocumentId("56789");
    changeLog2.setUserEdited("admin@sw360.org");
    changeLog2.setChangeTimestamp("2021-01-08");
    changeLog2.setOperation(Operation.CREATE);
    changeLog2.setDocumentType("attachment");
    changeLog2.setParentDocId("4567");
    HashMap<String, String> info = new HashMap<String, String>();
    info.put("FILENAME", "abc.xml");
    info.put("CONTENT_TYPE", "application/rdf+xml");
    info.put("PARENT_OPERATION", "PROJECT_UPDATE");
    changeLog2.setInfo(info);
    List<ChangeLogs> changeLogs = new ArrayList<ChangeLogs>();
    changeLogs.add(changeLog);
    changeLogs.add(changeLog2);
    given(this.changeLogServiceMock.getChangeLogsByDocumentId(anyObject(), anyObject())).willReturn(changeLogs);
}
Also used : ChangeLogs(org.eclipse.sw360.datahandler.thrift.changelogs.ChangeLogs) HashMap(java.util.HashMap) ReferenceDocData(org.eclipse.sw360.datahandler.thrift.changelogs.ReferenceDocData) ChangedFields(org.eclipse.sw360.datahandler.thrift.changelogs.ChangedFields) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

HashSet (java.util.HashSet)2 ReferenceDocData (org.eclipse.sw360.datahandler.thrift.changelogs.ReferenceDocData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 ChangeLogs (org.eclipse.sw360.datahandler.thrift.changelogs.ChangeLogs)1 ChangedFields (org.eclipse.sw360.datahandler.thrift.changelogs.ChangedFields)1 Component (org.eclipse.sw360.datahandler.thrift.components.Component)1 Release (org.eclipse.sw360.datahandler.thrift.components.Release)1 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)1 Before (org.junit.Before)1