Files
bjugl e786da42e8 Fixed: Induction from DB does not represent relations properly. (#290) (OFBIZ-12178)
As encountered in OFBIZ-6510, the ModelInduceFromDb does currently not include entity relations and foreign key constraints. Since they are an important part of the database model, we should fix that.

I could track down the problem to an incomplete invocation of the ModelEntity through the constructor used in the DatabaseUtil.induceModelFromDb() Methods. This constructor does not initialize the Relations.

Problem is, that the ModelEntity initialized through the "DB Names Constructor" does not cover references in its current state at all.

While working on an implementation I realized, that the API is not very congruent in this regards. I would expect that I could initialize ModelRelations the same way ModelFields are initialized in this context:

The create() Method takes a ModelEntity, DatabaseUtil.ColumnCheckInfo (respectively a DatabaseUtil.ReferenceCheckInfo) and a ModelFieldTypeReader (that could be left out for references) and creates ModelField (ModelRelation) objects that are added to the ModelEntity.

But that is not the case at the moment. On one hand not all fields that would be necessary are covered in the DatabaseUtil.ReferenceCheckInfo Objects (e.g. "type" is missing), on the other the object is missing public getters to make the values available in the first place.

Thanks a bunch Benjamin, nice add !
2021-04-02 11:12:42 +02:00

63 lines
2.3 KiB
Plaintext

<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<div class="page-title"><span>${uiLabelMap.WebtoolsModelInduceFromDb}</span></div>
<form class="basic-form" method="post" action="<@ofbizUrl>CreateModelInduceFromDb</@ofbizUrl>">
<table class="basic-table" cellspacing="0">
<tbody>
</tr>
<td class="label">
<label>${uiLabelMap.ModelInduceDatasourceName}</label>
</td>
<td>
<input type="text" name="datasourceName"/>
</td>
</tr>
<tr>
<td class="label">
<label>${uiLabelMap.ModelInducePackageName}</label>
</td>
<td>
<input type="text" name="packageName"/>
</td>
</tr>
<tr>
<td></td>
<td>
<select name="induceType">
<option value="entitymodel">${uiLabelMap.ModelInduceEntityModel}</option>
<option value="entitygroup">${uiLabelMap.ModelInduceEntityGroup}</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submitButton"/>
</td><td></td>
</tr>
</tbody>
</table>
</form>
</hr>
<div>${uiLabelMap.typeAndTitleDisclaimer}</div>
<div>${uiLabelMap.pleaseAddManually}</div>
</hr>
<div>
<textarea cols="60" rows="50" name="${uiLabelMap.ModelInduceInducedText}">${inducedText!}</textarea>
</div>