queryList.add(getQuery(queryIterator.next(), context));
}
}
private Descriptor buildDescriptor(PersistenceContext context, String persistenceUnit, ClassDescriptor descriptor, String baseUri) {
Descriptor returnDescriptor = new Descriptor();
String name = descriptor.getAlias();
returnDescriptor.setName(name);
String version = context.getVersion();
if (version != null) {
version = version + "/";
returnDescriptor.getLinkTemplates().add(new LinkTemplate("find", "get", baseUri + version + persistenceUnit + "/entity/" + descriptor.getAlias() + "/{primaryKey}"));
returnDescriptor.getLinkTemplates().add(new LinkTemplate("persist", "put", baseUri + version + persistenceUnit + "/entity/" + descriptor.getAlias()));
returnDescriptor.getLinkTemplates().add(new LinkTemplate("update", "post", baseUri + version + persistenceUnit + "/entity/" + descriptor.getAlias()));
returnDescriptor.getLinkTemplates().add(new LinkTemplate("delete", "delete", baseUri + version + persistenceUnit + "/entity/" + descriptor.getAlias() + "/{primaryKey}"));
} else {
returnDescriptor.getLinkTemplates().add(new LinkTemplate("find", "get", baseUri + persistenceUnit + "/entity/" + descriptor.getAlias() + "/{primaryKey}"));
returnDescriptor.getLinkTemplates().add(new LinkTemplate("persist", "put", baseUri + persistenceUnit + "/entity/" + descriptor.getAlias()));
returnDescriptor.getLinkTemplates().add(new LinkTemplate("update", "post", baseUri + persistenceUnit + "/entity/" + descriptor.getAlias()));
returnDescriptor.getLinkTemplates().add(new LinkTemplate("delete", "delete", baseUri + persistenceUnit + "/entity/" + descriptor.getAlias() + "/{primaryKey}"));
}
if (!descriptor.getMappings().isEmpty()) {
Iterator<DatabaseMapping> mappingIterator = descriptor.getMappings().iterator();
while (mappingIterator.hasNext()) {
DatabaseMapping mapping = mappingIterator.next();
addMapping(returnDescriptor, mapping);
}
}
addQueries(returnDescriptor.getQueries(), context, descriptor.getJavaClassName());
return returnDescriptor;
}