All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.aschet.spdx.licensecompat.graph.io.LicenseVertexProvider Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2017 Thomas Ascher 
 * SPDX-License-Identifier: LGPL-3.0+
 */

package com.github.aschet.spdx.licensecompat.graph.io;

import java.util.Map;

import org.jgrapht.ext.VertexProvider;
import org.spdx.rdfparser.license.LicenseInfoFactory;
import org.spdx.spdxspreadsheet.InvalidLicenseStringException;

import com.github.aschet.spdx.licensecompat.graph.LicenseVertex;
import com.github.aschet.spdx.licensecompat.utils.Utils;

/**
 * Part of {@link LicenseCompatGraphImporter} to create the correct vertex type.
 *
 * @author Thomas Ascher
 */
final class LicenseVertexProvider implements VertexProvider {

	@Override
	public LicenseVertex buildVertex(final String label, final Map attributes) {
		final LicenseVertex vertex = new LicenseVertex();
		final String licenseID = attributes.get("label");

		try {
			vertex.setLicenses(LicenseInfoFactory.parseSPDXLicenseString(licenseID));
		} catch (final InvalidLicenseStringException e) {
			vertex.setLicenses(Utils.createExtractedLicenseInfo(licenseID));
		}

		return vertex;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy