Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Mar 9, 2015
2 parents 7024e4a + c0aadba commit 4290723
Show file tree
Hide file tree
Showing 30 changed files with 1,495 additions and 413 deletions.
2 changes: 1 addition & 1 deletion gui/admin-gui/pom.xml
Expand Up @@ -338,7 +338,7 @@
<groupId>com.evolveum.midpoint.model</groupId>
<artifactId>report-impl</artifactId>
<version>3.2-SNAPSHOT</version>
<scope>runtime</scope>
<!-- <scope>runtime,compile</scope> -->
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.infra</groupId>
Expand Down
Expand Up @@ -430,7 +430,7 @@ public boolean isVisible() {
});
body.add(activationBlock);

DropDownChoicePanel administrativeStatus = WebMiscUtil.createActivationStatusPanel(ID_ADMINISTRATIVE_STATUS,
DropDownChoicePanel administrativeStatus = WebMiscUtil.createEnumPanel(ActivationStatusType.class, ID_ADMINISTRATIVE_STATUS,
new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "."
+ ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this);
activationBlock.add(administrativeStatus);
Expand Down
Expand Up @@ -16,6 +16,7 @@

package com.evolveum.midpoint.web.component.prism;

import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
Expand Down Expand Up @@ -384,12 +385,15 @@ public String createAssociationTooltip(){
}

Panel panel;

if (ActivationType.F_ADMINISTRATIVE_STATUS.equals(definition.getName())) {
return WebMiscUtil.createActivationStatusPanel(id, new PropertyModel<ActivationStatusType>(model, baseExpression), this);
return WebMiscUtil.createEnumPanel(ActivationStatusType.class, id, new PropertyModel<ActivationStatusType>(model, baseExpression), this);
} else if(ActivationType.F_LOCKOUT_STATUS.equals(definition.getName())){
return WebMiscUtil.createLockoutStatsPanel(id, new PropertyModel<LockoutStatusType>(model, baseExpression), this);
return WebMiscUtil.createEnumPanel(LockoutStatusType.class, id, new PropertyModel<LockoutStatusType>(model, baseExpression), this);
} else{

}

if (DOMUtil.XSD_DATETIME.equals(valueType)) {
panel = new DatePanel(id, new PropertyModel<XMLGregorianCalendar>(model, baseExpression));
} else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) {
Expand Down Expand Up @@ -454,6 +458,12 @@ public DeltaDto getObject() {
Class type = XsdTypeMapper.getXsdToJavaMapping(valueType);
if (type != null && type.isPrimitive()) {
type = ClassUtils.primitiveToWrapper(type);

}

if (isEnum(property)) {
return WebMiscUtil.createEnumPanel(definition, id, new PropertyModel<>(model, baseExpression), this);

}
// // default QName validation is a bit weird, so let's treat QNames as strings [TODO finish this - at the parsing side]
// if (type == QName.class) {
Expand All @@ -465,6 +475,20 @@ public DeltaDto getObject() {
return panel;
}

private boolean isEnum(PrismProperty property){
PrismPropertyDefinition definition = property.getDefinition();
//// Object realValue = property.getAnyRealValue();
if (definition == null){
return property.getValueClass().isEnum();
}
//
// QName defName = definition.getName();
// Class clazz = definition.getPrismContext().getSchemaRegistry().determineCompileTimeClass(defName);
//
// return ((clazz != null && clazz.isEnum()) || ActivationType.F_ADMINISTRATIVE_STATUS.equals(definition.getName())
// || ActivationType.F_LOCKOUT_STATUS.equals(definition.getName()) || );
return (definition.getAllowedValues() != null && definition.getAllowedValues().length > 0);
}
//TODO - try to get rid of <br> attributes when creating new lines in association attributes pop-up
private String createAssociationTooltipText(PrismProperty property){
StringBuilder sb = new StringBuilder();
Expand Down
@@ -0,0 +1,7 @@
package com.evolveum.midpoint.web.component.util;

public interface Validatable {

public boolean isEmpty();

}
Expand Up @@ -34,7 +34,9 @@
import com.evolveum.midpoint.web.component.util.PrismPropertyModel;
import com.evolveum.midpoint.web.page.admin.configuration.PageAdminConfiguration;
import com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel;
import com.evolveum.midpoint.web.page.admin.reports.component.JasperReportConfigurationPanel;
import com.evolveum.midpoint.web.page.admin.reports.component.ReportConfigurationPanel;
import com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto;
import com.evolveum.midpoint.web.page.error.PageError;
import com.evolveum.midpoint.web.util.Base64Model;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
Expand All @@ -50,6 +52,7 @@
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.util.string.StringValue;
import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidator;
Expand Down Expand Up @@ -83,21 +86,21 @@ public class PageReport<T extends Serializable> extends PageAdminReports {
private static final String ID_SAVE_BUTTON = "save";
private static final String ID_CANCEL_BUTTON = "cancel";

private LoadableModel<PrismObject<ReportType>> model;
private LoadableModel<ReportDto> model;

public PageReport() {
model = new LoadableModel<PrismObject<ReportType>>(false) {
model = new LoadableModel<ReportDto>(false) {

@Override
protected PrismObject<ReportType> load() {
protected ReportDto load() {
return loadReport();
}
};

initLayout();
}

private PrismObject<ReportType> loadReport() {
private ReportDto loadReport() {
StringValue reportOid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);

OperationResult result = new OperationResult(OPERATION_LOAD_REPORT);
Expand All @@ -107,8 +110,10 @@ private PrismObject<ReportType> loadReport() {
LOGGER.error("Couldn't load report.");
throw new RestartResponseException(PageReports.class);
}

return new ReportDto(prismReport.asObjectable());

return prismReport;
// return prismReport;
}

private void initLayout() {
Expand All @@ -127,31 +132,32 @@ public WebMarkupContainer getPanel(String panelId) {

@Override
public WebMarkupContainer getPanel(String panelId) {
IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplate");
IModel<String> data = new Base64Model(new PrismPropertyModel<>(model, ReportType.F_TEMPLATE));
return new AceEditorPanel(panelId, title, data);
return new JasperReportConfigurationPanel(panelId, model);
// IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplate");
// IModel<String> data = new Base64Model(new PrismPropertyModel<>(model, ReportType.F_TEMPLATE));
// return new AceEditorPanel(panelId, title, data);
}
});
tabs.add(new AbstractTab(createStringResource("PageReport.jasperTemplateStyle")) {

@Override
public WebMarkupContainer getPanel(String panelId) {
IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplateStyle");
IModel<String> data = new Base64Model(new PrismPropertyModel<>(model, ReportType.F_TEMPLATE_STYLE));
IModel<String> data = new Base64Model(new PropertyModel(model, "templateStyle"));
return new AceEditorPanel(panelId, title, data);
}
});
tabs.add(new AbstractTab(createStringResource("PageReport.fullXml")) {

@Override
public WebMarkupContainer getPanel(String panelId) {
IModel<String> title = PageReport.this.createStringResource("PageReport.fullXml");

AceEditorPanel panel = new AceEditorPanel(panelId, title, createFullXmlModel());
panel.getEditor().add(createFullXmlValidator());
return panel;
}
});
// tabs.add(new AbstractTab(createStringResource("PageReport.fullXml")) {
//
// @Override
// public WebMarkupContainer getPanel(String panelId) {
// IModel<String> title = PageReport.this.createStringResource("PageReport.fullXml");
//
// AceEditorPanel panel = new AceEditorPanel(panelId, title, createFullXmlModel());
// panel.getEditor().add(createFullXmlValidator());
// return panel;
// }
// });

TabbedPanel reportTabPanel = new TabbedPanel(ID_TAB_PANEL, tabs){
@Override
Expand Down Expand Up @@ -215,7 +221,7 @@ private IModel<String> createFullXmlModel() {

@Override
public String getObject() {
PrismObject report = model.getObject();
PrismObject report = model.getObject().getObject();
if (report == null) {
return null;
}
Expand All @@ -235,7 +241,7 @@ public void setObject(String object) {

try {
validateObject(object, reportHolder, true, result);
model.setObject(reportHolder.getValue());
model.getObject().setObject(reportHolder.getValue());
} catch (Exception e){
LOGGER.error("Could not set object. Validation problem occured." + result.getMessage());
result.recordFatalError("Could not set object. Validation problem occured,", e);
Expand Down Expand Up @@ -284,7 +290,8 @@ protected void onSavePerformed(AjaxRequestTarget target) {
try {
Task task = createSimpleTask(OPERATION_SAVE_REPORT);

PrismObject<ReportType> newReport = model.getObject();
//TODO TODO TODO
PrismObject<ReportType> newReport = model.getObject().getObject();
PrismObject<ReportType> oldReport = WebModelUtils.loadObject(ReportType.class, newReport.getOid(),
result, this);

Expand Down
@@ -0,0 +1,58 @@
<!--
~ Copyright (c) 2010-2013 Evolveum
~
~ Licensed 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.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<!-- <h3 style="margin-left: 20px;" wicket:id="title"/> -->

<div class="form-group">
<div class="col-lg-12">

<div wicket:id="parametersTitle"/>
<div wicket:id="parametersTable"/>

<div class="main-button-bar" style="margin-left: 20px;">
<span class="button-group">
<a class="btn btn-success" wicket:id="addParameter" />

</span>

<a class="btn btn-danger" wicket:id="deleteParameter"/>
</div>

<div wicket:id="query"/>


<div wicket:id="fieldsTitle"/>
<div wicket:id="fieldsTable"/>


<div class="main-button-bar" style="margin-left: 20px;">
<span class="button-group">
<a class="btn btn-success" wicket:id="addField" />

</span>

<a class="btn btn-danger" wicket:id="deleteField"/>
</div>

<div wicket:id="template"/>
</div>
</div>

</wicket:panel>
</html>

0 comments on commit 4290723

Please sign in to comment.