Skip to content

Commit

Permalink
KAA-1146: Added validation for fileds on EventClassView page.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchizhevsky committed Aug 15, 2016
1 parent 523f644 commit 4414d79
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 61 deletions.
Expand Up @@ -71,7 +71,6 @@ public void onClick(ClickEvent event) {
CtlSchemaPlace newCtlPlace = null;

newCtlPlace = new CtlSchemaPlace("", null, CTLSchemaScopeDto.TENANT, place.getEcfId(), place.getEcfVersionId(), place.getEcfVersion(), true, true);
newCtlPlace.setEventClassDtoList(place.getEventClassDtoList());
newCtlPlace.setSchemaType(getPlaceSchemaType());
newCtlPlace.setPreviousPlace(place);
canceled = true;
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.kaaproject.kaa.server.admin.client.mvp.place.ConfigurationSchemasPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.CtlSchemaPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.CtlSchemaPlace.SchemaType;
import org.kaaproject.kaa.server.admin.client.mvp.place.EcfVersionPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.EventClassPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.LogSchemasPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.NotificationSchemasPlace;
Expand Down Expand Up @@ -66,6 +65,7 @@ public class CtlSchemaActivity extends AbstractDetailsActivity<CtlSchemaFormDto,

protected Integer version = null;
private String ctlSchemaID;
private String nameEC;

public CtlSchemaActivity(CtlSchemaPlace place, ClientFactory clientFactory) {
super(place, clientFactory);
Expand Down Expand Up @@ -396,7 +396,10 @@ public void onSuccessImpl(CtlSchemaFormDto result) {
} else if (place.getSchemaType() == SchemaType.LOG_SCHEMA) {
goTo(new LogSchemasPlace(place.getApplicationId()));
} else if (place.getSchemaType() == SchemaType.EVENT_CLASS && place.getPreviousPlace() != null) {
goTo(new EventClassPlace(place.getEcfId(), place.getEcfVersionId(), place.getEcfVersion(), "", ctlSchemaID, place.getEventClassDtoList()));
EventClassPlace eventClassPlace = new EventClassPlace(place.getEcfId(), place.getEcfVersionId(), place.getEcfVersion(), "");
eventClassPlace.setCtlSchemaId(ctlSchemaID);
eventClassPlace.setNameEC(nameEC);
goTo(eventClassPlace);
}
} else if (place.getPreviousPlace() != null) {
goTo(place.getPreviousPlace());
Expand Down Expand Up @@ -506,6 +509,7 @@ public void onFailureImpl(Throwable caught) {
@Override
public void onSuccessImpl(EventClassViewDto eventClassViewDto) {
ctlSchemaID = eventClassViewDto.getSchema().getCtlSchemaId();
nameEC = eventClassViewDto.getSchema().getName();
callback.onSuccess(null);
}
});
Expand Down
Expand Up @@ -165,7 +165,7 @@ protected void editEntity(EventClassFamilyDto entity,
}

private void addEcfVersion() {
EcfVersionPlace ecfVersionPlace = new EcfVersionPlace(entityId, "", -1);
EcfVersionPlace ecfVersionPlace = new EcfVersionPlace(entityId, "", -1, null);
ecfVersionPlace.setPreviousPlace(place);
goTo(ecfVersionPlace);
}
Expand Down
Expand Up @@ -77,18 +77,17 @@ protected void editEntity(EventClassViewDto eventClassViewDto,

List<EventClassViewDto> eventClassDtoList = place.getEventClassDtoList();
if (eventClassDtoList != null && eventClassViewDto.getCtlSchemaForm() != null) {
int sizeArrays = eventClassDtoList.size();
for (int i = 0; i < sizeArrays; i++) {
for (int i = 0; i < eventClassDtoList.size(); i++) {
if (eventClassDtoList.get(i).getId() == eventClassViewDto.getId()) {
EventClassDto eventClassDto = eventClassDtoList.get(i).getSchema();
eventClassDto.setName(eventClassViewDto.getSchema().getName());
eventClassDtoList.get(i).setSchema(eventClassDto);
EventClassViewDto updatedECV = eventClassDtoList.get(i);
updatedECV.setSchema(eventClassDto);
eventClassDtoList.set(i, updatedECV);
i = sizeArrays;
}
}
place.setEventClassDtoList(eventClassDtoList);
} else {
place.addEventClassViewDto(eventClassViewDto);
}
Expand Down Expand Up @@ -146,14 +145,6 @@ public void onFailureImpl(Throwable caught) {
});
}

@Override
protected void bindDetailsView(boolean fireChanged) {
super.bindDetailsView(fireChanged);
if (entity.getSchema().getType() != null) {
detailsView.getEventClassTypes().setValue(entity.getSchema().getType().toString());
}
}

@Override
protected void onEntityRetrieved() {
super.onEntityRetrieved();
Expand Down Expand Up @@ -184,6 +175,7 @@ public void onFailure(Throwable caught) {
@Override
public void onSuccess(CtlSchemaReferenceDto ctlSchemaReferenceDto) {
detailsView.getCtlSchemaReference().setValue(ctlSchemaReferenceDto);
detailsView.getName().setValue(place.getNameEC());
place.setCtlSchemaId(null);
}
});
Expand Down
Expand Up @@ -18,7 +18,6 @@

import com.google.gwt.place.shared.PlaceTokenizer;
import com.google.web.bindery.event.shared.EventBus;
import org.kaaproject.kaa.server.admin.shared.schema.EventClassViewDto;

public abstract class AbstractSchemaPlaceEvent extends SchemasPlaceEvent {

Expand Down Expand Up @@ -47,6 +46,7 @@ public P getPlace(String token) {
public String getToken(P place) {
PlaceParams.clear();
PlaceParams.putParam(ECF_ID, place.getEcfId());
PlaceParams.putParam(ECF_VERSION, String.valueOf(place.getEcfVersion()));
PlaceParams.putParam(ECF_VERSION_ID, place.getEcfVersionId());
PlaceParams.putParam(SCHEMA_ID, String.valueOf(place.getSchemaId()));
return PlaceParams.generateToken();
Expand Down
Expand Up @@ -40,7 +40,6 @@ public class CtlSchemaPlace extends TreePlace {
private String ecfId;
private int ecfVersion;
private String ecfVersionId;
private List<EventClassViewDto> eventClassDtoList;

public CtlSchemaPlace(String metaInfoId,
Integer version,
Expand Down Expand Up @@ -74,14 +73,6 @@ public CtlSchemaPlace(String metaInfoId,
this.create = create;
}

public List<EventClassViewDto> getEventClassDtoList() {
return eventClassDtoList;
}

public void setEventClassDtoList(List<EventClassViewDto> eventClassDtoList) {
this.eventClassDtoList = eventClassDtoList;
}

public void setSchemaType(SchemaType schemaType) {
this.schemaType = schemaType;
}
Expand Down
Expand Up @@ -32,10 +32,6 @@ public EcfVersionPlace(String ecfId, String ecfVersionId, int ecfVersion, List<E
super(ecfId, ecfVersionId, ecfVersion, eventClassViewDtoList);
}

public List<EventClassViewDto> getEventClassDtoList() {
return eventClassDtoList;
}

public int getEcfVersion() {
return ecfVersion;
}
Expand Down
Expand Up @@ -29,37 +29,15 @@
public class EventClassPlace extends AbstractSchemaPlaceEvent {

private String ctlSchemaId;

public EventClassPlace(String ecfId, String ecfVersionId, int ecfVersion, String schemaId) {
super(ecfId, ecfVersionId, ecfVersion, schemaId);
}

public EventClassPlace(String ecfId, String ecfVersionId, int ecfVersion, String schemaId, String ctlSchemaId, List<EventClassViewDto> eventClassDtoList) {
super(ecfId, ecfVersionId, ecfVersion, schemaId);
this.ctlSchemaId = ctlSchemaId;
this.eventClassDtoList = eventClassDtoList;

}
private String nameEC;

public EventClassPlace(String ecfId, String ecfVersionId, int ecfVersion, String schemaId, List<EventClassViewDto> eventClassDtoList) {
super(ecfId, ecfVersionId, ecfVersion, schemaId);
this.eventClassDtoList = eventClassDtoList;
}

public void addEventClassViewDto(EventClassViewDto eventClassViewDto) {
if (eventClassDtoList == null) {
this.eventClassDtoList = new ArrayList<>();
}
eventClassDtoList.add(eventClassViewDto);

}

public List<EventClassViewDto> getEventClassDtoList() {
return eventClassDtoList;
}

public void setEventClassDtoList(List<EventClassViewDto> eventClassDtoList) {
this.eventClassDtoList = eventClassDtoList;
public EventClassPlace(String ecfId, String ecfVersionId, int ecfVersion, String schemaId) {
super(ecfId, ecfVersionId, ecfVersion, schemaId);
}

public String getCtlSchemaId() {
Expand All @@ -70,6 +48,14 @@ public void setCtlSchemaId(String ctlSchemaId) {
this.ctlSchemaId = ctlSchemaId;
}

public String getNameEC() {
return nameEC;
}

public void setNameEC(String nameEC) {
this.nameEC = nameEC;
}

@Override
public String getName() {
return Utils.constants.schemas();
Expand All @@ -87,7 +73,7 @@ protected EventClassPlace getPlaceImpl(String ecfId, String ecfVersionId, int ec

@Override
public TreePlace createDefaultPreviousPlace() {
return new EcfVersionPlace(ecfId, ecfVersionId, ecfVersion, eventClassDtoList);
return new EcfVersionPlace(ecfId, ecfVersionId, ecfVersion, eventClassDtoList);
}

@Override
Expand Down
Expand Up @@ -30,7 +30,7 @@ public class SchemasPlaceEvent extends TreePlace {
protected String ecfId;
protected String ecfVersionId;
protected int ecfVersion;
protected List<EventClassViewDto> eventClassDtoList;
protected static List<EventClassViewDto> eventClassDtoList;

private SchemasPlaceDataProvider dataProvider;

Expand All @@ -47,6 +47,21 @@ public SchemasPlaceEvent(String ecfId, String ecfVersionId, int ecfVersion, List
this.eventClassDtoList = eventClassDtoList;
}

public void addEventClassViewDto(EventClassViewDto eventClassViewDto) {
if (eventClassDtoList == null) {
this.eventClassDtoList = new ArrayList<>();
}
eventClassDtoList.add(eventClassViewDto);
}

public static List<EventClassViewDto> getEventClassDtoList() {
return eventClassDtoList;
}

public void setEventClassDtoList(List<EventClassViewDto> eventClassDtoList) {
this.eventClassDtoList = eventClassDtoList;
}

public String getEcfId() {
return ecfId;
}
Expand All @@ -55,10 +70,6 @@ public String getEcfVersionId() {
return ecfVersionId;
}

public List<EventClassViewDto> getEventClassDtoList() {
return eventClassDtoList;
}

public int getEcfVersion() {
return ecfVersion;
}
Expand Down Expand Up @@ -105,7 +116,7 @@ class SchemasPlaceDataProvider extends TreePlaceDataProvider {

@Override
protected void loadData(LoadCallback callback,
HasData<TreePlace> display) {
HasData<TreePlace> display) {
List<TreePlace> result = new ArrayList<TreePlace>();
result.add(new EcfVersionPlace(ecfId, ecfVersionId, ecfVersion, eventClassDtoList));
callback.onSuccess(result, display);
Expand Down
Expand Up @@ -16,13 +16,18 @@

package org.kaaproject.kaa.server.admin.client.mvp.view.event;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import org.kaaproject.avro.ui.gwt.client.widget.grid.AbstractGrid;
import org.kaaproject.avro.ui.gwt.client.widget.grid.event.RowActionEvent;
import org.kaaproject.avro.ui.gwt.client.widget.grid.event.RowActionEventHandler;
import org.kaaproject.kaa.common.dto.event.EventClassDto;
import org.kaaproject.kaa.common.dto.user.UserVerifierDto;
import org.kaaproject.kaa.server.admin.client.mvp.view.EcfVersionView;
import org.kaaproject.kaa.server.admin.client.mvp.view.base.BaseListViewImpl;
import org.kaaproject.kaa.server.admin.client.mvp.view.schema.BaseCtlSchemasGrid;
Expand Down Expand Up @@ -68,4 +73,10 @@ public Button addButtonEventClass() {
return addSchemaButton;
}

public void validateAddButton() {
if (grid.getDataGrid().getVisibleItems().isEmpty()) {
addButton.setEnabled(false);
}
}

}
Expand Up @@ -71,4 +71,11 @@ protected String getSubTitle() {
public ValueListBox<String> getEventClassTypes() {
return eventClassTypeName;
}

@Override
protected boolean validate() {
boolean result = super.validate();
result &= eventClassTypeName.getValue().length() > 0;
return result;
}
}

0 comments on commit 4414d79

Please sign in to comment.