Springfox displays duplicate models in the swagger ui - spring-rest

I have two models Package and File. Both are JPA entities that are annotated with #ApiModel. Also there is a ManyToMany relationship between them.
There are other classes that reference Package and File though.
I already added a value to the #ApiModel annotation.
#ApiModel(value = "the package")
public class Package {
#ManyToMany(cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
})
#JoinTable(
name = "file_package",
joinColumns = #JoinColumn(name = "file_id"),
inverseJoinColumns = #JoinColumn(name = "package_id")
)
#ApiModelProperty(name = "The list of files")
private List<File> files = new ArrayList<>();
}
In the swagger ui (localhost:8080/swagger-ui.html#/), the Package model appears 3 times as:
Package
Package_1
Package_2
Package_3
The weird part is that if I create a REST controller that uses Package or File I get this error:
java.lang.IllegalStateException: Ambiguous models equality when conditions is empty.
at springfox.documentation.spring.web.scanners.ApiModelReader.checkCondition(ApiModelReader.java:655)
at springfox.documentation.spring.web.scanners.ApiModelReader.mergeConditions(ApiModelReader.java:537)
at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:236)
at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:149)
at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:144)

Still, an open issue
Related to spring data-rest. Hope for fix in next release.
https://github.com/springfox/springfox/issues/3014?_pjax=%23js-repo-pjax-container

Related

DynamicJasper and OneToMany

I have a two classes that are in OneToMany relationship:
Lager and supplier.
so when i have list of objects, i have also object and with standard java i can access fields of object.
when i do this
AbstractColumn columnName = ColumnBuilder.getNew()
.setColumnProperty("name", String.class.getName())
.setTitle("Name").setWidth(85)
.build();
i get a good result, but when i do
AbstractColumn sellerColumn = ColumnBuilder.getNew()
.setColumnProperty("seller" ,Seller.class.getName() )
.setTitle("seller").setWidth(85).build();
i just get toString method of my seller object, so my question is how to access field of seller when i am creating my DynamicJasper column
so i added now a picture to better
#OneToMany(mappedBy ="seller", cascade = CascadeType.REMOVE,fetch=FetchType.LAZY)
public List<Lager> getLager() {
return lager;
}
#ManyToOne(fetch=FetchType.EAGER)
#JoinColumn(name = "seller_id")
public Seller getSeller() {
return seller.get();
}
this are the relations between these two objects, how could i just show name of my seller object, and not the entire toString method.
Well at the end i found a way, i changed following method :
AbstractColumn sellerColumn = ColumnBuilder.getNew()
.setColumnProperty("seller" ,Seller.class.getName() )
.setTitle("seller").setWidth(85).build();
to
AbstractColumn sellerColumn = ColumnBuilder.getNew()
.setColumnProperty("seller.seller_name" ,Seller.class.getName() )
.setTitle("seller").setWidth(85).build();
after that everything worked, the thing is , i did try this, but for some reason my page did not load properly, when i did clean and build it worked flawlessly.
just to note that seller.seller_name is :
seller = my pojo class
and
seller_name
= my field that has getters and setters.

Alfresco error: Model '{custom.model}custommodel' does not exist

Using Alfresco 5.0 community edition.
When trying to deploy the custom model provided in the answer to another question,
but using the dynamic deployment approach as specified at [http://docs.alfresco.com/5.0/tasks/deploy-dynamic.html]
Although the GUI says the model is "activated", I get the following WARN in the alfresco.log:
21:24:30,587 WARN [org.alfresco.repo.dictionary.DictionaryDAO] [ajp-apr-8009-exec-4]
org.alfresco.service.cmr.dictionary.DictionaryException:
00140008 Model '{custom.model}custommodel' does not exist
When I try to use it with CMIS 1.1, I'm getting an error back from the web service:
Type 'P:cmod:customDoc' is unknown!
Here is the relevant bit of the code which uses opencmis java api:
Map<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:document");
props.put("cmis:secondaryObjectTypeIds", Arrays.asList(new String[] {"P:cm:titled", "P:cmod:customDoc"}));
props.put("cmis:name", "myName");
props.put("cmod:property1", "value1");
ObjectId id = folder.createDocument(props, contentStream, VersioningState.MAJOR);
Am I specifying the namespace and aspect correctly (P:cmod:customDoc)? I've also tried cmod:aspectBase and other combinations, getting the same error.
My goal is to make a simple model where I can add a few extra fields to document objects (extending the default ContentModel).
It seems the warning is just that, it can be ignored.
But using CMIS 1.1, I have to do two steps to add in the extra properties from the custom aspect. (Trying to do it in one step gives the error "Type 'P:cmod:customDoc' is unknown!")
First createDocument() with the cmis:secondaryObjectTypeIds including the custom namespace, BUT don't add any custom properties.
Second, add the custom properties to the resulting document, and then updateProperties(). This will add in the custom property values to the document.
Map<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:document");
props.put("cmis:secondaryObjectTypeIds",
Arrays.asList(new String[] {"P:cm:titled", "P:cmod:customDoc"}));
props.put("cmis:name", "myName");
Document document = folder.createDocument(props, contentStream, VersioningState.MAJOR);
props = new HashMap<String, Object>();
props.put("cmod:property1", "value1"); //here is where you add the custom properties
document = (Document) document.updateProperties(properties);
(note: you need to reassign the document from the updateProperties result, otherwise it will be missing some information, such as parents)

"Unexpected list type" exception when invoking ISessionAwareCoreService.GetList()

I am invoking the Tridion 2011 SP1 core service via the shipped client assembly. When I attempt to list the contents of a publication, I get an exception.
The code (simplified) looks like this:
ItemsFilterData filter = new Tridion.ContentManager.CoreService
.Client.RepositoryItemsFilterData.RepositoryItemsFilterData();
filter.ItemTypes = new ItemType[] {
ItemType.Folder,
ItemType.StructureGroup
};
filter.Recursive = false;
IEnumerable<IdentifiableObjectData> childItems = core.GetList("tcm:0-15-1", filter);
Note: the variable "core" refers to an ISessionAwareCoreService which I can successfully use to call, for example core.GetSystemWideList()
When .GetList is invoked, I get the following exception:
System.ServiceModel.FaultException`1 was unhandled
Message=Unexpected list type:
Tridion.ContentManager.Data.ContentManagement.RepositoryItemsFilterData.
What are the possible causes of this problem? Can you suggest a good general approach for interpreting this kind of message?
You can't get the direct children of a Publication using GetList. Instead you should just load the PublicationData with a client.Read and then access the RootFolder and RootStructureGroup on that.
PublicationData pub = (PublicationData)core.Read("tcm:0-1-1", new ReadOptions());
string rootFolder = pub.RootFolder.IdRef;
string rootSG = pub.RootStructureGroup.IdRef;
Alternatively you can call GetListXml with your RepositoryItemsFilterData and extract the items from the XML yourself.
XElement listResult = core.GetListXml(parent.ID, filter);

Creating a UI object repository for webdriver

For those familiar with automated testing tools, you know that they all have some kind of "object repository" that stores a mapping of UI elements with identifiers. I have found this to be indispensible and I want to duplicate this for webdriver. Has anyone done this ? Any tips ? Google not helping on this one. C# examples if you can, thanks
I use Webinator (which wraps around WebDriver) but the idea is the same - I usually do a static "Map" class like so:
public static class CollectionMap
{
public static Locator
LocatorTitle = new Locator(FindBy.Id, "Title"),
LocatorDescription = new Locator(FindBy.Id, "Description"),
LocatorSave = new Locator(FindBy.Id, "submit"),
LocatorDelete = new Locator(FindBy.XPath, "//*[contains(#class,'deleteBox')]/a"),
LocatorDeleteConfirm = new Locator(FindBy.Id, "delete-collection-dialogConfirmationLink"),
LocatorCancel = new Locator(FindBy.Id, "cancel");
}
Used like this:
web.Click(CollectionMap.LocatorSave, WaitUntil.AjaxOrPostCompleted());
I am creating multiple classes containing mappings to locators. Each class corresponds to a logical grouping of screen elements.
public class TopLevel
{
public const string username = "ctl00_ctl00_Main_Main_txtUsername";
}

problem with TreeListNode

I'm trying to create a treelistnode. The following below code getting an error:
private TreeListNode CreateTreeNode(EntityInfo entity)
{
CategoryInfo info = entity as CategoryInfo;
TreeListNode treeNode = new TreeListNode();
treeNode.SetValue("CatName", info.CatName);
treeNode.SetValue("CateCode", info.CateCode);
treeNode.SetValue("Id", info.Id);
treeNode.Tag = info.Id;
return treeNode;
}
Error
DevExpress.XtraTreeList.Nodes.TreeListNode.TreeListNode(int, DevExpress.XtraTreeList.Nodes.TreeListNodes)' is inaccessible due to its protection level
I need your help to create a separate treelistnode
Thanks!
You should use the TreeList's AppendNode method instead. Please also refer to the How to: Create Nodes in Unbound Mode in Code topic.

Resources