if ( metadataFacetModel == null )
{
metadataFacetModel = new MetadataFacetModel();
}
// we need to store the repositoryId
ArtifactMetadataModel artifactMetadataModel = new ArtifactMetadataModel();
artifactMetadataModel.setRepositoryId( repositoryId );
metadataFacetModel.setArtifactMetadataModel( artifactMetadataModel );
metadataFacetModel.setId( key );
metadataFacetModel.setFacetId( metadataFacet.getFacetId() );
metadataFacetModel.setName( metadataFacet.getName() );
try
{
getMetadataFacetModelEntityManager().put( metadataFacetModel );
}
catch ( PersistenceException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
else
{
for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
{
String key = new MetadataFacetModel.KeyBuilder().withRepositoryId( repositoryId ).withFacetId(
metadataFacet.getFacetId() ).withName( metadataFacet.getName() ).withKey( entry.getKey() ).build();
MetadataFacetModel metadataFacetModel = getMetadataFacetModelEntityManager().get( key );
if ( metadataFacetModel == null )
{
metadataFacetModel = new MetadataFacetModel();
// we need to store the repositoryId
ArtifactMetadataModel artifactMetadataModel = new ArtifactMetadataModel();
artifactMetadataModel.setRepositoryId( repositoryId );
metadataFacetModel.setArtifactMetadataModel( artifactMetadataModel );
metadataFacetModel.setId( key );
metadataFacetModel.setKey( entry.getKey() );
metadataFacetModel.setFacetId( metadataFacet.getFacetId() );
metadataFacetModel.setName( metadataFacet.getName() );