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; CtlSchemaPlace newCtlPlace = null;


newCtlPlace = new CtlSchemaPlace("", null, CTLSchemaScopeDto.TENANT, place.getEcfId(), place.getEcfVersionId(), place.getEcfVersion(), true, true); newCtlPlace = new CtlSchemaPlace("", null, CTLSchemaScopeDto.TENANT, place.getEcfId(), place.getEcfVersionId(), place.getEcfVersion(), true, true);
newCtlPlace.setEventClassDtoList(place.getEventClassDtoList());
newCtlPlace.setSchemaType(getPlaceSchemaType()); newCtlPlace.setSchemaType(getPlaceSchemaType());
newCtlPlace.setPreviousPlace(place); newCtlPlace.setPreviousPlace(place);
canceled = true; 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.ConfigurationSchemasPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.CtlSchemaPlace; 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.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.EventClassPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.LogSchemasPlace; import org.kaaproject.kaa.server.admin.client.mvp.place.LogSchemasPlace;
import org.kaaproject.kaa.server.admin.client.mvp.place.NotificationSchemasPlace; 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; protected Integer version = null;
private String ctlSchemaID; private String ctlSchemaID;
private String nameEC;


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


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


List<EventClassViewDto> eventClassDtoList = place.getEventClassDtoList(); List<EventClassViewDto> eventClassDtoList = place.getEventClassDtoList();
if (eventClassDtoList != null && eventClassViewDto.getCtlSchemaForm() != null) { if (eventClassDtoList != null && eventClassViewDto.getCtlSchemaForm() != null) {
int sizeArrays = eventClassDtoList.size(); for (int i = 0; i < eventClassDtoList.size(); i++) {
for (int i = 0; i < sizeArrays; i++) {
if (eventClassDtoList.get(i).getId() == eventClassViewDto.getId()) { if (eventClassDtoList.get(i).getId() == eventClassViewDto.getId()) {
EventClassDto eventClassDto = eventClassDtoList.get(i).getSchema(); EventClassDto eventClassDto = eventClassDtoList.get(i).getSchema();
eventClassDto.setName(eventClassViewDto.getSchema().getName()); eventClassDto.setName(eventClassViewDto.getSchema().getName());
eventClassDtoList.get(i).setSchema(eventClassDto); eventClassDtoList.get(i).setSchema(eventClassDto);
EventClassViewDto updatedECV = eventClassDtoList.get(i); EventClassViewDto updatedECV = eventClassDtoList.get(i);
updatedECV.setSchema(eventClassDto); updatedECV.setSchema(eventClassDto);
eventClassDtoList.set(i, updatedECV); eventClassDtoList.set(i, updatedECV);
i = sizeArrays;
} }
} }
place.setEventClassDtoList(eventClassDtoList);
} else { } else {
place.addEventClassViewDto(eventClassViewDto); 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 @Override
protected void onEntityRetrieved() { protected void onEntityRetrieved() {
super.onEntityRetrieved(); super.onEntityRetrieved();
Expand Down Expand Up @@ -184,6 +175,7 @@ public void onFailure(Throwable caught) {
@Override @Override
public void onSuccess(CtlSchemaReferenceDto ctlSchemaReferenceDto) { public void onSuccess(CtlSchemaReferenceDto ctlSchemaReferenceDto) {
detailsView.getCtlSchemaReference().setValue(ctlSchemaReferenceDto); detailsView.getCtlSchemaReference().setValue(ctlSchemaReferenceDto);
detailsView.getName().setValue(place.getNameEC());
place.setCtlSchemaId(null); place.setCtlSchemaId(null);
} }
}); });
Expand Down
Expand Up @@ -18,7 +18,6 @@


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


public abstract class AbstractSchemaPlaceEvent extends SchemasPlaceEvent { public abstract class AbstractSchemaPlaceEvent extends SchemasPlaceEvent {


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


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


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

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

public void setSchemaType(SchemaType schemaType) { public void setSchemaType(SchemaType schemaType) {
this.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); super(ecfId, ecfVersionId, ecfVersion, eventClassViewDtoList);
} }


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

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


private String ctlSchemaId; private String ctlSchemaId;

private String nameEC;
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;

}


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


public void addEventClassViewDto(EventClassViewDto eventClassViewDto) { public EventClassPlace(String ecfId, String ecfVersionId, int ecfVersion, String schemaId) {
if (eventClassDtoList == null) { super(ecfId, ecfVersionId, ecfVersion, schemaId);
this.eventClassDtoList = new ArrayList<>();
}
eventClassDtoList.add(eventClassViewDto);

}

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

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


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


public String getNameEC() {
return nameEC;
}

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

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


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


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


private SchemasPlaceDataProvider dataProvider; private SchemasPlaceDataProvider dataProvider;


Expand All @@ -47,6 +47,21 @@ public SchemasPlaceEvent(String ecfId, String ecfVersionId, int ecfVersion, List
this.eventClassDtoList = eventClassDtoList; 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() { public String getEcfId() {
return ecfId; return ecfId;
} }
Expand All @@ -55,10 +70,6 @@ public String getEcfVersionId() {
return ecfVersionId; return ecfVersionId;
} }


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

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


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


package org.kaaproject.kaa.server.admin.client.mvp.view.event; 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.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel; 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.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.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.EcfVersionView;
import org.kaaproject.kaa.server.admin.client.mvp.view.base.BaseListViewImpl; import org.kaaproject.kaa.server.admin.client.mvp.view.base.BaseListViewImpl;
import org.kaaproject.kaa.server.admin.client.mvp.view.schema.BaseCtlSchemasGrid; import org.kaaproject.kaa.server.admin.client.mvp.view.schema.BaseCtlSchemasGrid;
Expand Down Expand Up @@ -68,4 +73,10 @@ public Button addButtonEventClass() {
return addSchemaButton; 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() { public ValueListBox<String> getEventClassTypes() {
return eventClassTypeName; 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.