fix more json mapping

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295530 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-01 12:12:31 +00:00
parent 65dd1c69b6
commit 0ff4db1523
1 changed files with 30 additions and 30 deletions

View File

@ -315,58 +315,58 @@ $(function() {
this.artifact=false; this.artifact=false;
} }
mapVersionsList=function(data){ mapVersionsList=function(data){
if (data.versionsList){ if (data){
if (data.versionsList.versions){ if (data.versions){
return $.isArray(data.versionsList.versions)? $.map(data.versionsList.versions,function(item){return item}) return $.isArray(data.versions)? $.map(data.versions,function(item){return item})
:[data.versionsList.versions]; :[data.versions];
} }
} }
return []; return [];
} }
mapProjectVersionMetadata=function(data){ mapProjectVersionMetadata=function(data){
if (data && data.projectVersionMetadata){ if (data){
var projectVersionMetadata = var projectVersionMetadata =
new ProjectVersionMetadata(data.projectVersionMetadata.id,data.projectVersionMetadata.url, new ProjectVersionMetadata(data.id,data.url,
data.projectVersionMetadata.name,data.projectVersionMetadata.description, data.name,data.description,
null,null,null,null,null,null,null,data.projectVersionMetadata.incomplete); null,null,null,null,null,null,null,data.incomplete);
if (data.projectVersionMetadata.organization){ if (data.organization){
projectVersionMetadata.organization=new Organization(data.projectVersionMetadata.organization.name,data.projectVersionMetadata.organization.url); organization=new Organization(data.organization.name,data.organization.url);
} }
if (data.projectVersionMetadata.issueManagement){ if (data.issueManagement){
projectVersionMetadata.issueManagement= issueManagement=
new IssueManagement(data.projectVersionMetadata.issueManagement.system,data.projectVersionMetadata.issueManagement.url); new IssueManagement(data.issueManagement.system,data.issueManagement.url);
} }
if (data.projectVersionMetadata.scm){ if (data.scm){
projectVersionMetadata.scm= scm=
new Scm(data.projectVersionMetadata.scm.connection,data.projectVersionMetadata.scm.developerConnection,data.projectVersionMetadata.scm.url); new Scm(data.scm.connection,data.scm.developerConnection,data.scm.url);
} }
if (data.projectVersionMetadata.ciManagement){ if (data.ciManagement){
projectVersionMetadata.ciManagement=new CiManagement(data.projectVersionMetadata.ciManagement.system,data.projectVersionMetadata.ciManagement.url); ciManagement=new CiManagement(data.ciManagement.system,data.ciManagement.url);
} }
if (data.projectVersionMetadata.licenses){ if (data.licenses){
var licenses = var licenses =
$.isArray(data.projectVersionMetadata.licenses) ? $.map(data.projectVersionMetadata.licenses,function(item){ $.isArray(data.licenses) ? $.map(data.licenses,function(item){
return new License(item.name,item.url); return new License(item.name,item.url);
}):[data.projectVersionMetadata.licenses]; }):[data.licenses];
projectVersionMetadata.licenses=licenses; licenses=licenses;
} }
if (data.projectVersionMetadata.mailingLists){ if (data.mailingLists){
var mailingLists = var mailingLists =
$.isArray(data.projectVersionMetadata.mailingLists) ? $.map(data.projectVersionMetadata.mailingLists,function(item){ $.isArray(data.mailingLists) ? $.map(data.mailingLists,function(item){
return new MailingList(item.mainArchiveUrl,item.otherArchives,item.name,item.postAddress, return new MailingList(item.mainArchiveUrl,item.otherArchives,item.name,item.postAddress,
item.subscribeAddress,item.unsubscribeAddress); item.subscribeAddress,item.unsubscribeAddress);
}):[data.projectVersionMetadata.mailingLists]; }):[data.mailingLists];
projectVersionMetadata.mailingLists=mailingLists; mailingLists=mailingLists;
} }
if (data.projectVersionMetadata.dependencies){ if (data.dependencies){
var dependencies = var dependencies =
$.isArray(data.projectVersionMetadata.dependencies) ? $.map(data.projectVersionMetadata.dependencies,function(item){ $.isArray(data.dependencies) ? $.map(data.dependencies,function(item){
return new Dependency(item.classifier,item.optional,item.scope,item.systemPath,item.type, return new Dependency(item.classifier,item.optional,item.scope,item.systemPath,item.type,
item.artifactId,item.groupId,item.version); item.artifactId,item.groupId,item.version);
}):[data.projectVersionMetadata.dependencies]; }):[data.dependencies];
projectVersionMetadata.dependencies=dependencies; dependencies=dependencies;
} }
$.log("projectVersionMetadata.issueManagement.system:"+(projectVersionMetadata.issueManagement?projectVersionMetadata.issueManagement.system:"null")); $.log("projectVersionMetadata.issueManagement.system:"+(projectVersionMetadata.issueManagement?projectVersionMetadata.issueManagement.system:"null"));
return projectVersionMetadata; return projectVersionMetadata;