Skip to content

Commit

Permalink
KAA-1146: merged with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
vchizhevsky committed Aug 15, 2016
1 parent 9bc301e commit a860ef2
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 123 deletions.
Expand Up @@ -102,7 +102,7 @@ public void onClick(ClickEvent event) {
registrations.add(listView.getAddButton().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {

KaaAdmin.getDataSource().saveEventClassFamilyVersion(place.getEcfId(), place.getEventClassDtoList(),
KaaAdmin.getDataSource().addEventClassFamilyVersionFromView(place.getEcfId(), place.getEventClassDtoList(),
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
Expand Down
Expand Up @@ -36,9 +36,9 @@
import org.kaaproject.kaa.common.dto.ProfileFilterRecordDto;
import org.kaaproject.kaa.common.dto.ProfileVersionPairDto;
import org.kaaproject.kaa.common.dto.ServerProfileSchemaDto;
import org.kaaproject.kaa.common.dto.TenantDto;
import org.kaaproject.kaa.common.dto.TopicDto;
import org.kaaproject.kaa.common.dto.VersionDto;
import org.kaaproject.kaa.common.dto.admin.*;
import org.kaaproject.kaa.common.dto.admin.RecordKey.RecordFiles;
import org.kaaproject.kaa.common.dto.admin.SchemaVersions;
import org.kaaproject.kaa.common.dto.admin.SdkPlatform;
Expand Down Expand Up @@ -69,6 +69,7 @@
import org.kaaproject.kaa.server.admin.shared.schema.ConverterType;
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.EventClassViewDto;
import org.kaaproject.kaa.server.admin.shared.schema.LogSchemaViewDto;
import org.kaaproject.kaa.server.admin.shared.schema.NotificationSchemaViewDto;
import org.kaaproject.kaa.server.admin.shared.schema.ProfileSchemaViewDto;
Expand Down Expand Up @@ -233,7 +234,7 @@ public void loadTenants(final AsyncCallback<List<TenantDto>> callback) {
public void loadTenants(final AsyncCallback<List<TenantDto>> callback,
boolean refresh) {
if (tenants == null || refresh) {
tenants = new ArrayList<>();
tenants = new ArrayList<TenantDto>();
tenantRpcService.getTenants(new DataCallback<List<TenantDto>>(callback) {
@Override
protected void onResult(List<TenantDto> result) {
Expand Down Expand Up @@ -490,7 +491,7 @@ protected void onResult(RecordField result) {

public void generateEcfVersionForm(String fileItemName,
final AsyncCallback<RecordField> callback) {
rpcService.generateEcfSchemaForm(fileItemName,
eventRpcService.generateEcfSchemaForm(fileItemName,
new DataCallback<RecordField>(callback) {
@Override
protected void onResult(RecordField result) {
Expand Down Expand Up @@ -548,7 +549,7 @@ protected void onResult(EventClassFamilyDto result) {
}

public void getEventClassView(String eventClassId, final AsyncCallback<EventClassViewDto> callback) {
rpcService.getEventClassView(eventClassId, new DataCallback<EventClassViewDto>(callback) {
eventRpcService.getEventClassView(eventClassId, new DataCallback<EventClassViewDto>(callback) {
@Override
protected void onResult(EventClassViewDto result) {
}
Expand All @@ -557,7 +558,7 @@ protected void onResult(EventClassViewDto result) {
}

public void getEventClassViewByCtlSchemaId(EventClassDto eventClassViewDto, final AsyncCallback<EventClassViewDto> callback) {
rpcService.getEventClassViewByCtlSchemaId(eventClassViewDto, new DataCallback<EventClassViewDto>(callback) {
eventRpcService.getEventClassViewByCtlSchemaId(eventClassViewDto, new DataCallback<EventClassViewDto>(callback) {
@Override
protected void onResult(EventClassViewDto result) {
}
Expand All @@ -566,7 +567,7 @@ protected void onResult(EventClassViewDto result) {
}

public void saveEventClassView(EventClassViewDto eventClassViewDto, final AsyncCallback<EventClassViewDto> callback) {
rpcService.saveEventClassView(eventClassViewDto, new DataCallback<EventClassViewDto>(callback) {
eventRpcService.saveEventClassView(eventClassViewDto, new DataCallback<EventClassViewDto>(callback) {
@Override
protected void onResult(EventClassViewDto result) {
}
Expand All @@ -575,7 +576,7 @@ protected void onResult(EventClassViewDto result) {
}

public void createEventClassFormCtlSchema(CtlSchemaFormDto ctlSchemaFormDto, final AsyncCallback<EventClassViewDto> callback) {
rpcService.createEventClassFormCtlSchema(ctlSchemaFormDto , new DataCallback<EventClassViewDto>(callback) {
eventRpcService.createEventClassFormCtlSchema(ctlSchemaFormDto , new DataCallback<EventClassViewDto>(callback) {
@Override
protected void onResult(EventClassViewDto result) {
}
Expand All @@ -584,7 +585,7 @@ protected void onResult(EventClassViewDto result) {
}

public void getEventClassTypes(final AsyncCallback<List<String>> callback) {
rpcService.getEventClassTypes(new DataCallback<List<String>>(callback) {
eventRpcService.getEventClassTypes(new DataCallback<List<String>>(callback) {
@Override
protected void onResult(List<String> result) {
}
Expand All @@ -593,7 +594,7 @@ protected void onResult(List<String> result) {
}

public void getEventClassFamilyVersions(String eventClassFamilyId, final AsyncCallback<List<EventClassFamilyVersionDto>> callback) {
rpcService.getEventClassFamilyVersions(eventClassFamilyId, new DataCallback<List<EventClassFamilyVersionDto>>(callback) {
eventRpcService.getEventClassFamilyVersions(eventClassFamilyId, new DataCallback<List<EventClassFamilyVersionDto>>(callback) {
@Override
protected void onResult(List<EventClassFamilyVersionDto> result) {
}
Expand All @@ -602,27 +603,27 @@ protected void onResult(List<EventClassFamilyVersionDto> result) {
}

public void getLastCtlSchemaReferenceDto(String ctlSchemaId, final AsyncCallback<CtlSchemaReferenceDto> callback) {
rpcService.getLastCtlSchemaReferenceDto(ctlSchemaId, new DataCallback<CtlSchemaReferenceDto>(callback) {
ctlRpcService.getLastCtlSchemaReferenceDto(ctlSchemaId, new DataCallback<CtlSchemaReferenceDto>(callback) {
@Override
protected void onResult(CtlSchemaReferenceDto result) {
}
});

}

public void saveEventClassFamilyVersion(String eventClassFamilyId, List<EventClassViewDto> eventClassViewDto, final AsyncCallback<Void> callback) {
rpcService.saveEventClassFamilyVersion(eventClassFamilyId, eventClassViewDto,
public void addEventClassFamilyVersionFromView(String eventClassFamilyId, List<EventClassViewDto> eventClassViewDto, final AsyncCallback<Void> callback) {
eventRpcService.addEventClassFamilyVersionFromView(eventClassFamilyId, eventClassViewDto,
new DataCallback<Void>(callback) {
@Override
protected void onResult(Void result) {
eventBus.fireEvent(new DataEvent(EventSchemaVersionDto.class));
eventBus.fireEvent(new DataEvent(EventClassFamilyVersionDto.class)); //: todo
}
});
}

public void getEventClassesByFamilyIdVersionAndType(String eventClassFamilyId, int version, EventClassType type,
final AsyncCallback<List<EventClassDto>> callback) {
rpcService.getEventClassesByFamilyIdVersionAndType(eventClassFamilyId, version, type,
eventRpcService.getEventClassesByFamilyIdVersionAndType(eventClassFamilyId, version, type,
new DataCallback<List<EventClassDto>>(callback) {
@Override
protected void onResult(List<EventClassDto> result) {
Expand All @@ -632,7 +633,7 @@ protected void onResult(List<EventClassDto> result) {

public void addEventClassFamilyVersion(String eventClassFamilyId, EventClassFamilyVersionDto eventClassFamilyVersion,
final AsyncCallback<Void> callback) {
rpcService.addEventClassFamilyVersion(eventClassFamilyId, eventClassFamilyVersion,
eventRpcService.addEventClassFamilyVersion(eventClassFamilyId, eventClassFamilyVersion,
new DataCallback<Void>(callback) {
@Override
protected void onResult(Void result) {
Expand Down Expand Up @@ -948,19 +949,19 @@ protected void onResult(List<CTLSchemaMetaInfoDto> result) {
});
}

public void getLastCreatedCTLSchemaByFqnAndVersion(String fqn, Integer version,
final AsyncCallback<CTLSchemaMetaInfoDto> callback) {
rpcService.getLastCreatedCTLSchemaByFqnAndVersion(fqn, version,
new DataCallback<CTLSchemaMetaInfoDto>(callback) {
@Override
protected void onResult(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,
final AsyncCallback<CTLSchemaDto> callback) {
rpcService.getCTLSchemaById(ctlSchemaId,
ctlRpcService.getCTLSchemaById(ctlSchemaId,
new DataCallback<CTLSchemaDto>(callback) {
@Override
protected void onResult(CTLSchemaDto result) {
Expand Down
Expand Up @@ -58,7 +58,7 @@ public void setNameEC(String nameEC) {

@Override
public String getName() {
return Utils.constants.schemas();
return Utils.constants.versions();
}

@Prefix(value = "eventClass")
Expand Down
Expand Up @@ -42,7 +42,7 @@ public String getApplicationId() {

@Override
public String getName() {
return Utils.constants.schemas();
return Utils.constants.versions();
}

public static abstract class Tokenizer<P extends SchemasPlaceApplication> implements PlaceTokenizer<P>, PlaceConstants {
Expand Down
Expand Up @@ -76,7 +76,7 @@ public int getEcfVersion() {

@Override
public String getName() {
return Utils.constants.schemas();
return Utils.constants.versions();
}

public static abstract class Tokenizer<P extends SchemasPlaceEvent> implements PlaceTokenizer<P>, PlaceConstants {
Expand Down
Expand Up @@ -166,7 +166,7 @@ protected void initDetailsTable() {

ecfVersionsGrid = new EcfVersionsGrid();
ecfVersionsGrid.setSize("700px", "200px");
Label ecfVersionsLabel = new Label(Utils.constants.schemas());
Label ecfVersionsLabel = new Label(Utils.constants.versions());
ecfVersionsLabel.addStyleName(Utils.kaaAdminStyle.bAppContentTitleLabel());

addEcfVersionButton = new Button(Utils.constants.addSchema());
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.kaaproject.kaa.common.dto.event.EcfInfoDto;
import org.kaaproject.kaa.common.dto.event.EventClassDto;
import org.kaaproject.kaa.common.dto.event.EventClassFamilyDto;
import org.kaaproject.kaa.common.dto.event.EventClassFamilyVersionDto;
import org.kaaproject.kaa.common.dto.event.EventClassType;
import org.kaaproject.kaa.server.admin.shared.services.KaaAdminServiceException;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -113,36 +114,6 @@ public EventClassFamilyDto editEventClassFamily(
return eventService.editEventClassFamily(eventClassFamily);
}

/**
* Adds the event class family schema to the event class family with
* specific id. Current user will be marked as creator of schema.
*
* @param eventClassFamilyId the event class family id
* @param file the file
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Add event class family schema",
notes = "Adds the event class family schema to the event class family with the specified ID. The current user will be marked as the creator of " +
"schema. Only users with the TENANT_ADMIN role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified event class family schema is not a valid avro schema"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN) or the Tenant ID of the specified " +
"event class family does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "A file with the event class family schema was not found in the form data or an event class family with the " +
"specified ID does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "addEventClassFamilySchema", method = RequestMethod.POST, consumes = {"multipart/mixed", "multipart/form-data"})
@ResponseStatus(value = HttpStatus.OK)
public void addEventClassFamilySchema(
@ApiParam(name = "eventClassFamilyId", value = "A unique event class family identifier", required = true)
@RequestPart(value = "eventClassFamilyId") String eventClassFamilyId,
@ApiParam(name = "file", value = "Event class family schema represented in json format", required = true)
@RequestPart("file") MultipartFile file) throws KaaAdminServiceException {
byte[] data = getFileContent(file);
eventService.addEventClassFamilySchema(eventClassFamilyId, data);
}

/**
* Gets the event classes by family its id, version and type.
*
Expand Down Expand Up @@ -299,4 +270,51 @@ public List<AefMapInfoDto> getEventClassFamiliesByApplicationToken(
return eventService.getEventClassFamiliesByApplicationToken(applicationToken);
}

/**
* Gets the event class family versions by its id.
*
* @param eventClassFamilyId
* the event class family id
* @return the list of event class family version dto
* @throws KaaAdminServiceException
* the kaa admin service exception
*/
@RequestMapping(value = "eventClassFamilyVersions/{eventClassFamilyId}", method = RequestMethod.GET)
@ResponseBody
public List<EventClassFamilyVersionDto> getEventClassFamilyVersions(@PathVariable String eventClassFamilyId) throws KaaAdminServiceException {
return eventService.getEventClassFamilyVersions(eventClassFamilyId);
}

/**
* Adds the event class family version to existing event class family with
* specific id. Current user will be marked as creator of schema.
*
* @param eventClassFamilyId
* the event class family id
* @param eventClassFamilyVersion
* the version of event class family
* @throws KaaAdminServiceException
* the kaa admin service exception
*/
@ApiOperation(value = "Add event class family schema",
notes = "Adds the event class family schema to the event class family with the specified ID. The current user will be marked as the creator of " +
"schema. Only users with the TENANT_ADMIN role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified event class family schema is not a valid avro schema"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN) or the Tenant ID of the specified " +
"event class family does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "A file with the event class family schema was not found in the form data or an event class family with the " +
"specified ID does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "addEventClassFamilyVersion", method = RequestMethod.POST, consumes = { "multipart/mixed", "multipart/form-data" })
@ResponseStatus(value = HttpStatus.OK)
public void addEventClassFamilyVersion(
@ApiParam(name = "eventClassFamilyId", value = "A unique event class family identifier", required = true)
@RequestPart(value = "eventClassFamilyId") String eventClassFamilyId,
@ApiParam(name = "eventClassFamilyVersion", value = "Version of ECF", required = true)
@RequestPart(value = "eventClassFamilyVersion") EventClassFamilyVersionDto eventClassFamilyVersion) throws KaaAdminServiceException {
eventService.addEventClassFamilyVersion(eventClassFamilyId, eventClassFamilyVersion);
}

}
Expand Up @@ -412,9 +412,8 @@ public CtlSchemaFormDto saveCTLSchemaForm(CtlSchemaFormDto ctlSchemaForm, Conver
@Override
public List<CtlSchemaReferenceDto> getAvailableApplicationCTLSchemaReferences(String applicationId)
throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER, KaaAuthorityDto.TENANT_ADMIN);
try {
this.checkApplicationId(applicationId);
AuthUserDto currentUser = getCurrentUser();
List<CtlSchemaReferenceDto> result = new ArrayList<>();
List<CTLSchemaMetaInfoDto> availableMetaInfo = controlService.getAvailableCTLSchemasMetaInfoForApplication(currentUser.getTenantId(), applicationId);
Expand Down Expand Up @@ -655,4 +654,19 @@ private String asText(Collection<CTLSchemaDto> types) {
return message.toString();
}

@Override
public CtlSchemaReferenceDto getLastCtlSchemaReferenceDto(String ctlSchemaId) throws KaaAdminServiceException {
try {
if (!isEmpty(ctlSchemaId)) {
CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(ctlSchemaId);
CtlSchemaReferenceDto ctlSchemaReference = getAvailableApplicationCTLSchemaReferences(null).stream().
filter(ctlSchemaReferenceDto -> ctlSchemaReferenceDto.getMetaInfo().getId().equals(ctlSchemaDto.getMetaInfo().getId())).findFirst().get();
return ctlSchemaReference;
}
} catch (Exception e) {
throw Utils.handleException(e);
}
return null;
}

}

0 comments on commit a860ef2

Please sign in to comment.