Skip to content

Commit

Permalink
KAA-1146: Admin-UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vchizhevsky committed Aug 16, 2016
1 parent b57bc30 commit 9ba7be4
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 81 deletions.
Expand Up @@ -88,6 +88,8 @@ public interface EventClassService {
*/ */
List<EventClassDto> findEventClassesByFamilyIdVersionAndType(String ecfId, int version, EventClassType type); List<EventClassDto> findEventClassesByFamilyIdVersionAndType(String ecfId, int version, EventClassType type);


boolean validateEventClassFamilyFqns(String eventClassFamilyId, List<String> fqns);

/** /**
* Find event class family by tenant id and name. * Find event class family by tenant id and name.
* *
Expand Down Expand Up @@ -132,4 +134,6 @@ public interface EventClassService {
* @return the event class dto * @return the event class dto
*/ */
boolean isValidECFListInSdkProfile(List<AefMapInfoDto> ecfList); boolean isValidECFListInSdkProfile(List<AefMapInfoDto> ecfList);

List<String> getFqnListForECF(String eventClassId);
} }
Expand Up @@ -159,7 +159,7 @@ public void addEventClassFamilyVersion(String eventClassFamilyId,
for (EventClassDto eventClass : records) { for (EventClassDto eventClass : records) {
fqns.add(eventClass.getFqn()); fqns.add(eventClass.getFqn());
} }
if (validateEventClassFamilyFqns(eventClassFamily, fqns)) { if (validateEventClassFamilyFqns(eventClassFamily.getId(), fqns)) {
List<EventClassFamilyVersionDto> schemasDto = findEventClassFamilyVersionsById(eventClassFamilyId); List<EventClassFamilyVersionDto> schemasDto = findEventClassFamilyVersionsById(eventClassFamilyId);
int version = 1; int version = 1;
if (schemasDto != null && !schemasDto.isEmpty()) { if (schemasDto != null && !schemasDto.isEmpty()) {
Expand Down Expand Up @@ -206,12 +206,9 @@ private void setBackreference(List<EventClassFamilyVersion> ecfvList) {
ecfvList.forEach(ecfv -> ecfv.getRecords().forEach(ec -> ec.setEcfv(ecfv))); ecfvList.forEach(ecfv -> ecfv.getRecords().forEach(ec -> ec.setEcfv(ecfv)));
} }


private boolean validateEventClassFamilyFqns(EventClassFamilyDto eventClassFamily, List<String> fqns) { @Override
String ecfId = eventClassFamily.getId(); public boolean validateEventClassFamilyFqns(String eventClassFamilyId, List<String> fqns) {
EventClassFamily ecf = eventClassFamilyDao.findById(ecfId); List<String> storedFQNs = getFqnListForECF(eventClassFamilyId);
List<String> storedFQNs = new ArrayList<>();
ecf.getSchemas().forEach(ecfv -> ecfv.getRecords().forEach(ec -> storedFQNs.add(ec.getFqn())));

for (String storedFQN : storedFQNs) { for (String storedFQN : storedFQNs) {
long duplicatedFqnCount = fqns.stream().filter(fqn -> fqn.equals(storedFQN)).count(); long duplicatedFqnCount = fqns.stream().filter(fqn -> fqn.equals(storedFQN)).count();
if (duplicatedFqnCount > 0) return false; if (duplicatedFqnCount > 0) return false;
Expand Down Expand Up @@ -282,4 +279,17 @@ public boolean isValidECFListInSdkProfile(List<AefMapInfoDto> ecfList) {


return true; return true;
} }

@Override
public List<String> getFqnListForECF(String eventClassId) {
if (isValidSqlId(eventClassId)) {
LOG.debug("Find event class by id [{}] ", eventClassId);
List<String> storedFQNs = new ArrayList<>();
EventClassFamily ecf = eventClassFamilyDao.findById(eventClassId);
ecf.getSchemas().forEach(ecfv -> ecfv.getRecords().forEach(ec -> storedFQNs.add(ec.getFqn())));
return storedFQNs;
} else {
throw new IncorrectParameterException("Incorrect event class id: " + eventClassId);
}
}
} }
Expand Up @@ -79,7 +79,7 @@ public void onClick(ClickEvent event) {
} }
})); }));


KaaAdmin.getDataSource().getAvailableApplicationCTLSchemaReferences(null, new BusyAsyncCallback<List<CtlSchemaReferenceDto>>() { KaaAdmin.getDataSource().getTenantLevelCTLSchemaReferenceForECF(place.getEcfId(), place.getEventClassDtoList(), new BusyAsyncCallback<List<CtlSchemaReferenceDto>>() {
@Override @Override
public void onFailureImpl(Throwable caught) { public void onFailureImpl(Throwable caught) {
Utils.handleException(caught, detailsView); Utils.handleException(caught, detailsView);
Expand Down
Expand Up @@ -152,6 +152,19 @@ protected void onSave() {


List<String> aefMapIds = new ArrayList<>(); List<String> aefMapIds = new ArrayList<>();
List<AefMapInfoDto> aefMaps = detailsView.getSelectedAefMaps().getValues(); List<AefMapInfoDto> aefMaps = detailsView.getSelectedAefMaps().getValues();

KaaAdmin.getDataSource().validateECFListInSdkProfile(aefMaps, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
Utils.handleException(caught, detailsView);
}

@Override
public void onSuccess(Void aVoid) {

}
});

if (aefMaps != null) { if (aefMaps != null) {
for (AefMapInfoDto aefMap : aefMaps) { for (AefMapInfoDto aefMap : aefMaps) {
aefMapIds.add(aefMap.getAefMapId()); aefMapIds.add(aefMap.getAefMapId());
Expand Down
Expand Up @@ -36,6 +36,7 @@
import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaReferenceDto; import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaReferenceDto;
import org.kaaproject.kaa.server.admin.shared.schema.EventClassViewDto; import org.kaaproject.kaa.server.admin.shared.schema.EventClassViewDto;


import java.util.ArrayList;
import java.util.List; import java.util.List;


public class EventClassActivity public class EventClassActivity
Expand All @@ -61,13 +62,23 @@ protected EventClassView getView(boolean create) {


@Override @Override
protected void getEntity(String eventClassId, protected void getEntity(String eventClassId,
AsyncCallback<EventClassViewDto> callback) { final AsyncCallback<EventClassViewDto> callback) {
if (place.getEventClassDtoList() != null) { if (place.getEventClassDtoList() != null) {
EventClassDto eventClassDto = place.getEventClassDtoList().get(Integer.valueOf(eventClassId) - 1).getSchema(); EventClassDto eventClassDto = place.getEventClassDtoList().get(Integer.valueOf(eventClassId) - 1).getSchema();
KaaAdmin.getDataSource().getEventClassViewByCtlSchemaId(eventClassDto, callback); KaaAdmin.getDataSource().getEventClassViewByCtlSchemaId(eventClassDto, callback);
detailsView.getEventClassTypes().setValue(eventClassDto.getType().toString()); detailsView.getEventClassTypes().setValue(eventClassDto.getType().name());
} else { } else {
KaaAdmin.getDataSource().getEventClassView(eventClassId, callback); KaaAdmin.getDataSource().getEventClassView(eventClassId, new AsyncCallback<EventClassViewDto>() {
@Override
public void onFailure(Throwable caught) {
Utils.handleException(caught, EventClassActivity.this.detailsView);
}
@Override
public void onSuccess(EventClassViewDto eventClassViewDto) {
detailsView.getEventClassTypes().setValue(eventClassViewDto.getSchema().getType().name());
callback.onSuccess(eventClassViewDto);
}
});
} }
} }


Expand Down Expand Up @@ -150,18 +161,11 @@ protected void onEntityRetrieved() {
super.onEntityRetrieved(); super.onEntityRetrieved();
ValueListBox<String> eventClassTypes = this.detailsView.getEventClassTypes(); ValueListBox<String> eventClassTypes = this.detailsView.getEventClassTypes();
if (eventClassTypes != null) { if (eventClassTypes != null) {
KaaAdmin.getDataSource().getEventClassTypes(new AsyncCallback<List<String>>() { List<String> eventClassTypeList = new ArrayList<>();

for (EventClassType eventClassType : EventClassType.values()) {
@Override eventClassTypeList.add(eventClassType.name());
public void onFailure(Throwable caught) { }
Utils.handleException(caught, EventClassActivity.this.detailsView); EventClassActivity.this.detailsView.getEventClassTypes().setAcceptableValues(eventClassTypeList);
}

@Override
public void onSuccess(List<String> result) {
EventClassActivity.this.detailsView.getEventClassTypes().setAcceptableValues(result);
}
});
} }


if (place.getCtlSchemaId() != null) { if (place.getCtlSchemaId() != null) {
Expand Down
Expand Up @@ -584,15 +584,6 @@ protected void onResult(EventClassViewDto result) {


} }


public void getEventClassTypes(final AsyncCallback<List<String>> callback) {
eventRpcService.getEventClassTypes(new DataCallback<List<String>>(callback) {
@Override
protected void onResult(List<String> result) {
}
});

}

public void getEventClassFamilyVersions(String eventClassFamilyId, final AsyncCallback<List<EventClassFamilyVersionDto>> callback) { public void getEventClassFamilyVersions(String eventClassFamilyId, final AsyncCallback<List<EventClassFamilyVersionDto>> callback) {
eventRpcService.getEventClassFamilyVersions(eventClassFamilyId, new DataCallback<List<EventClassFamilyVersionDto>>(callback) { eventRpcService.getEventClassFamilyVersions(eventClassFamilyId, new DataCallback<List<EventClassFamilyVersionDto>>(callback) {
@Override @Override
Expand All @@ -616,7 +607,7 @@ public void addEventClassFamilyVersionFromView(String eventClassFamilyId, List<E
new DataCallback<Void>(callback) { new DataCallback<Void>(callback) {
@Override @Override
protected void onResult(Void result) { protected void onResult(Void result) {
eventBus.fireEvent(new DataEvent(EventClassFamilyVersionDto.class)); //: todo
} }
}); });
} }
Expand All @@ -641,6 +632,14 @@ protected void onResult(Void result) {
}); });
} }


public void validateECFListInSdkProfile(List<AefMapInfoDto> ecfList, final AsyncCallback<Void> callback) {
eventRpcService.validateECFListInSdkProfile(ecfList, new DataCallback<Void>(callback) {
@Override
protected void onResult(Void result) {
}
});
}

public void loadProfileSchemas(String applicationId, public void loadProfileSchemas(String applicationId,
final AsyncCallback<List<EndpointProfileSchemaDto>> callback) { final AsyncCallback<List<EndpointProfileSchemaDto>> callback) {
profileRpcService.getProfileSchemasByApplicationId(applicationId, profileRpcService.getProfileSchemasByApplicationId(applicationId,
Expand Down Expand Up @@ -788,6 +787,15 @@ protected void onResult(List<CtlSchemaReferenceDto> result) {
}); });
} }


public void getTenantLevelCTLSchemaReferenceForECF(String ecfId, List<EventClassViewDto> eventClassViewDtoList, final AsyncCallback<List<CtlSchemaReferenceDto>> callback) {
ctlRpcService.getTenantLevelCTLSchemaReferenceForECF(ecfId, eventClassViewDtoList,
new DataCallback<List<CtlSchemaReferenceDto>>(callback) {
@Override
protected void onResult(List<CtlSchemaReferenceDto> result) {
}
});
}

public void loadConfigurationSchemas(String applicationId, public void loadConfigurationSchemas(String applicationId,
final AsyncCallback<List<ConfigurationSchemaDto>> callback) { final AsyncCallback<List<ConfigurationSchemaDto>> callback) {
configurationRpcService.getConfigurationSchemasByApplicationId(applicationId, configurationRpcService.getConfigurationSchemasByApplicationId(applicationId,
Expand Down Expand Up @@ -949,16 +957,6 @@ protected void onResult(List<CTLSchemaMetaInfoDto> result) {
}); });
} }


// public void getLastCreatedCTLSchemaByFqnAndVersion(String fqn, Integer version,
// final AsyncCallback<CTLSchemaMetaInfoDto> callback) {
// ctlRpcService.getLastCreatedCTLSchemaByFqnAndVersion(fqn, version,
// new DataCallback<CTLSchemaMetaInfoDto>(callback) {
// @Override
// protected void onResult(CTLSchemaMetaInfoDto result) {
// }
// });
// }

public void getCTLSchemaById(String ctlSchemaId, public void getCTLSchemaById(String ctlSchemaId,
final AsyncCallback<CTLSchemaDto> callback) { final AsyncCallback<CTLSchemaDto> callback) {
ctlRpcService.getCTLSchemaById(ctlSchemaId, ctlRpcService.getCTLSchemaById(ctlSchemaId,
Expand Down
Expand Up @@ -16,44 +16,39 @@


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.AttachEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.dom.client.ClickHandler;
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.Window;
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.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.widget.ImageTextButton; import org.kaaproject.kaa.server.admin.client.mvp.view.widget.ImageTextButton;
import org.kaaproject.kaa.server.admin.client.util.Utils; import org.kaaproject.kaa.server.admin.client.util.Utils;


public class EcfVersionViewImpl extends BaseListViewImpl<EventClassDto> implements EcfVersionView { public class EcfVersionViewImpl extends BaseListViewImpl<EventClassDto> implements EcfVersionView {


@UiField @UiField
public final ImageTextButton addSchemaButton; public final ImageTextButton addECButton;


public EcfVersionViewImpl(boolean editable) { public EcfVersionViewImpl(boolean editable) {
super(true); super(true);
this.addSchemaButton = new ImageTextButton(Utils.resources.plus(), addButtonEventClassString()); this.addECButton = new ImageTextButton(Utils.resources.plus(), addButtonEventClassString());
addSchemaButton.setVisible(editable); addECButton.setVisible(editable);
addButton.setVisible(editable); addButton.setVisible(editable);
supportPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); supportPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
supportPanel.setWidth("300px"); supportPanel.setWidth("300px");
supportPanel.add(addSchemaButton); supportPanel.add(addECButton);
// grid.(new AttachEvent.Handler() { addButton.setEnabled(false);
// @Override addButton.addClickHandler(new ClickHandler() {
// public void onAttachOrDetach(AttachEvent event) { @Override
// validateAddButton(); public void onClick(ClickEvent clickEvent) {
// } validateAddECButton();
// }); }
});
} }


@Override @Override
Expand All @@ -63,12 +58,12 @@ protected AbstractGrid<EventClassDto, String> createGrid() {


@Override @Override
protected String titleString() { protected String titleString() {
return Utils.constants.eventClasses(); return Utils.constants.familyVersion();
} }


@Override @Override
protected String addButtonString() { protected String addButtonString() {
return "Save ECF version"; return Utils.constants.save();
} }


private String addButtonEventClassString() { private String addButtonEventClassString() {
Expand All @@ -77,12 +72,14 @@ private String addButtonEventClassString() {


@Override @Override
public Button addButtonEventClass() { public Button addButtonEventClass() {
return addSchemaButton; return addECButton;
} }


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


Expand Down
Expand Up @@ -169,7 +169,7 @@ protected void initDetailsTable() {
Label ecfVersionsLabel = new Label(Utils.constants.versions()); Label ecfVersionsLabel = new Label(Utils.constants.versions());
ecfVersionsLabel.addStyleName(Utils.kaaAdminStyle.bAppContentTitleLabel()); ecfVersionsLabel.addStyleName(Utils.kaaAdminStyle.bAppContentTitleLabel());


addEcfVersionButton = new Button(Utils.constants.addSchema()); addEcfVersionButton = new Button(Utils.constants.addFamilyVersion());
addEcfVersionButton.addStyleName(Utils.kaaAdminStyle.bAppButtonSmall()); addEcfVersionButton.addStyleName(Utils.kaaAdminStyle.bAppButtonSmall());


detailsTable.setWidget(6, 0, ecfVersionsLabel); detailsTable.setWidget(6, 0, ecfVersionsLabel);
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaExportKey; import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaExportKey;
import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaFormDto; import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaFormDto;
import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaReferenceDto; import org.kaaproject.kaa.server.admin.shared.schema.CtlSchemaReferenceDto;
import org.kaaproject.kaa.server.admin.shared.schema.EventClassViewDto;
import org.kaaproject.kaa.server.admin.shared.services.CtlService; import org.kaaproject.kaa.server.admin.shared.services.CtlService;
import org.kaaproject.kaa.server.admin.shared.services.KaaAdminServiceException; import org.kaaproject.kaa.server.admin.shared.services.KaaAdminServiceException;
import org.kaaproject.kaa.server.admin.shared.services.ServiceErrorCode; import org.kaaproject.kaa.server.admin.shared.services.ServiceErrorCode;
Expand Down Expand Up @@ -301,6 +302,35 @@ public List<CTLSchemaMetaInfoDto> getTenantLevelCTLSchemas() throws KaaAdminServ
} }
} }


@Override
public List<CtlSchemaReferenceDto> getTenantLevelCTLSchemaReferenceForECF(String ecfId, List<EventClassViewDto> eventClassViewDtoList) throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.TENANT_ADMIN, KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try {
AuthUserDto currentUser = getCurrentUser();
List<CTLSchemaMetaInfoDto> ctlSchemaReferenceDtoListForTenant = controlService.getAvailableCTLSchemasMetaInfoForTenant(currentUser.getTenantId());
List<String> fqnListOfCurrentECF = controlService.getFqnListForECF(ecfId);
if (eventClassViewDtoList != null) {
for (EventClassViewDto eventClassViewDto : eventClassViewDtoList) {
String fqn = eventClassViewDto.getExistingMetaInfo().getMetaInfo().getFqn();
if (!fqnListOfCurrentECF.contains(fqn)) {
fqnListOfCurrentECF.add(fqn);
}
}
}
List<CtlSchemaReferenceDto> availableCtlSchemaReferenceForECF = new ArrayList<>();
for (CTLSchemaMetaInfoDto metaInfo : ctlSchemaReferenceDtoListForTenant) {
if (!fqnListOfCurrentECF.contains(metaInfo.getFqn())) {
for (int version : metaInfo.getVersions()) {
availableCtlSchemaReferenceForECF.add(new CtlSchemaReferenceDto(metaInfo, version));
}
}
}
return availableCtlSchemaReferenceForECF;
} catch (Exception cause) {
throw Utils.handleException(cause);
}
}

@Override @Override
public List<CTLSchemaMetaInfoDto> getApplicationLevelCTLSchemasByAppToken(String applicationToken) throws KaaAdminServiceException { public List<CTLSchemaMetaInfoDto> getApplicationLevelCTLSchemasByAppToken(String applicationToken) throws KaaAdminServiceException {
return getApplicationLevelCTLSchemas(checkApplicationToken(applicationToken)); return getApplicationLevelCTLSchemas(checkApplicationToken(applicationToken));
Expand Down
Expand Up @@ -310,15 +310,6 @@ public EventClassViewDto createEventClassFormCtlSchema(CtlSchemaFormDto ctlSchem
} }
} }


@Override
public List<String> getEventClassTypes() throws KaaAdminServiceException {
List<String> eventClassTypeList = new ArrayList<>(EventClassType.values().length);
for (EventClassType eventClassType : EventClassType.values()) {
eventClassTypeList.add(eventClassType.name());
}
return eventClassTypeList;
}

@Override @Override
public void addEventClassFamilyVersionFromView(String eventClassFamilyId, List<EventClassViewDto> eventClassViewDto) throws KaaAdminServiceException { public void addEventClassFamilyVersionFromView(String eventClassFamilyId, List<EventClassViewDto> eventClassViewDto) throws KaaAdminServiceException {
EventClassFamilyVersionDto eventClassFamilyVersionDto = new EventClassFamilyVersionDto(); EventClassFamilyVersionDto eventClassFamilyVersionDto = new EventClassFamilyVersionDto();
Expand All @@ -337,6 +328,15 @@ public void addEventClassFamilyVersionFromView(String eventClassFamilyId, List<E
addEventClassFamilyVersion(eventClassFamilyId, eventClassFamilyVersionDto); addEventClassFamilyVersion(eventClassFamilyId, eventClassFamilyVersionDto);
} }


@Override
public void validateECFListInSdkProfile(List<AefMapInfoDto> ecfList) throws KaaAdminServiceException {
try {
controlService.validateECFListInSdkProfile(ecfList);
} catch (Exception e) {
throw Utils.handleException(e);
}
}

@Override @Override
public List<EventClassDto> getEventClassesByFamilyIdVersionAndType(String eventClassFamilyId, int version, EventClassType type) public List<EventClassDto> getEventClassesByFamilyIdVersionAndType(String eventClassFamilyId, int version, EventClassType type)
throws KaaAdminServiceException { throws KaaAdminServiceException {
Expand Down

0 comments on commit 9ba7be4

Please sign in to comment.