public DbModule getDbModule(final Module module) {
        final DbModule dbModule = new DbModule();

        dbModule.setName(module.getName());
        dbModule.setVersion(module.getVersion());
        dbModule.setPromoted(module.isPromoted());
        dbModule.setSubmodule(module.isSubmodule());
        dbModule.setCreatedDateTime(module.getCreatedDateTime());
        dbModule.setUpdatedDateTime(module.getUpdatedDateTime());

        // Artifact
        for (final Artifact artifact : module.getArtifacts()) {
            final DbArtifact dbArtifact = getDbArtifact(artifact);
            dbModule.addArtifact(dbArtifact);
        }

        // Dependencies
        for (final Dependency dependency : module.getDependencies()) {
            dbModule.addDependency(dependency.getTarget().getGavc(), dependency.getScope());
        }

        // SubModules
        final StringBuilder sb = new StringBuilder();
        for (final Module submodule : module.getSubmodules()) {
            final DbModule dbSubmodule = getDbModule(submodule);
            dbModule.addSubmodule(dbSubmodule);
            sb.setLength(0);
        }

        return dbModule;
    }
public DbModule getDbModule ( final Module module ) { final DbModule dbModule = new DbModule ( ) ; dbModule . setName ( module . getName ( ) ) ; dbModule . setVersion ( module . getVersion ( ) ) ; dbModule . setPromoted ( module . isPromoted ( ) ) ; dbModule . setSubmodule ( module . isSubmodule ( ) ) ; dbModule . setCreatedDateTime ( module . getCreatedDateTime ( ) ) ; dbModule . setUpdatedDateTime ( module . getUpdatedDateTime ( ) ) ; for ( final Artifact artifact : module . getArtifacts ( ) ) { final DbArtifact dbArtifact = getDbArtifact ( artifact ) ; dbModule . addArtifact ( dbArtifact ) ; } for ( final Dependency dependency : module . getDependencies ( ) ) { dbModule . addDependency ( dependency . getTarget ( ) . getGavc ( ) , dependency . getScope ( ) ) ; } final StringBuilder sb = new StringBuilder ( ) ; for ( final Module submodule : module . getSubmodules ( ) ) { final DbModule dbSubmodule = getDbModule ( submodule ) ; dbModule . addSubmodule ( dbSubmodule ) ; sb . setLength ( 0 ) ; } return dbModule ; }
Transform a module from client/server model to database model

@param module the module to transform
@return DbModule