@@ -0,0 +1,3681 @@
+package com.zenika.cudf.adapter;%0A%0Aimport com.zenika.cudf.model.Binary;%0Aimport com.zenika.cudf.model.BinaryId;%0Aimport com.zenika.cudf.model.CUDFDescriptor;%0Aimport org.apache.archiva.metadata.model.Dependency;%0Aimport org.apache.archiva.metadata.model.Organization;%0Aimport org.apache.archiva.metadata.model.ProjectVersionMetadata;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0A/**%0A * @author Antoine Rouaze %3Cantoine.rouaze@zenika.com%3E%0A */%0Apublic class ArchivaAdapter implements Adapter%3CSet%3CProjectVersionMetadata%3E%3E %7B%0A%0A    @Override%0A    public Set%3CProjectVersionMetadata%3E fromCUDF(CUDFDescriptor descriptor) %7B%0A        Set%3CProjectVersionMetadata%3E projectVersionMetadatas = new HashSet%3CProjectVersionMetadata%3E();%0A        Set%3CBinary%3E binaries = descriptor.getPackages();%0A        for (Binary binary : binaries) %7B%0A            BinaryId binaryId = binary.getBinaryId();%0A            ProjectVersionMetadata projectVersionMetadata = new ProjectVersionMetadata();%0A            Organization organization = new Organization();%0A            organization.setName(binaryId.getOrganisation());%0A            projectVersionMetadata.setOrganization(organization);%0A            projectVersionMetadata.setName(binaryId.getName());%0A            projectVersionMetadata.setId(binary.getRevision());%0A            List%3CDependency%3E archivaDependencies = convertDependencies(binary.getDependencies());%0A            projectVersionMetadata.setDependencies(archivaDependencies);%0A            projectVersionMetadatas.add(projectVersionMetadata);%0A        %7D%0A        return projectVersionMetadatas;%0A    %7D%0A%0A    private List%3CDependency%3E convertDependencies(Set%3CBinary%3E dependencies) %7B%0A        List%3CDependency%3E archivaDependencies = new ArrayList%3CDependency%3E();%0A        for (Binary dependency : dependencies) %7B%0A            BinaryId dependencyId = dependency.getBinaryId();%0A            Dependency archivaDependency = new Dependency();%0A            archivaDependency.setGroupId(dependencyId.getOrganisation());%0A            archivaDependency.setArtifactId(dependencyId.getName());%0A            archivaDependency.setVersion(dependency.getRevision());%0A            archivaDependency.setType(dependency.getType());%0A            archivaDependencies.add(archivaDependency);%0A        %7D%0A        return archivaDependencies;%0A    %7D%0A%0A    @Override%0A    public CUDFDescriptor toCUDF(Set%3CProjectVersionMetadata%3E descriptors) %7B%0A        CUDFDescriptor descriptor = new CUDFDescriptor();%0A        Set%3CBinary%3E binaries = new HashSet%3CBinary%3E();%0A        for (ProjectVersionMetadata projectVersionMetadata : descriptors) %7B%0A            BinaryId binaryId = new BinaryId(projectVersionMetadata.getName(), projectVersionMetadata.getOrganization().getName(), 0);%0A            Binary binary = new Binary(binaryId);%0A            binary.setRevision(projectVersionMetadata.getVersion());%0A            Set%3CBinary%3E dependencies = convertArchivaDependencies(projectVersionMetadata.getDependencies());%0A            binary.setDependencies(dependencies);%0A            binaries.add(binary);%0A        %7D%0A        descriptor.setPackages(binaries);%0A        return descriptor;%0A    %7D%0A%0A    private Set%3CBinary%3E convertArchivaDependencies(List%3CDependency%3E archivaDependencies) %7B%0A        Set%3CBinary%3E dependencies = new HashSet%3CBinary%3E();%0A        for (Dependency archivaDependency : archivaDependencies) %7B%0A            BinaryId dependencyId = new BinaryId(archivaDependency.getArtifactId(), archivaDependency.getGroupId(), 0);%0A            Binary dependency = new Binary(dependencyId);%0A            dependency.setRevision(archivaDependency.getVersion());%0A            dependencies.add(dependency);%0A        %7D%0A        return dependencies;%0A    %7D%0A%7D%0A

Add Archiva adapter.