Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -712,23 +712,16 @@ class WorkflowResource extends LazyLogging {
}

@GET
@Path("/owner_user")
def getOwnerUser(@QueryParam("wid") wid: Integer): User = {
@Produces(Array(MediaType.TEXT_PLAIN))
@Path("/owner_name")
def getOwnerName(@QueryParam("wid") wid: Integer): String = {
context
.select(
USER.UID,
USER.NAME,
USER.EMAIL,
USER.PASSWORD,
USER.GOOGLE_ID,
USER.ROLE,
USER.GOOGLE_AVATAR
)
.from(WORKFLOW_OF_USER)
.join(USER)
.on(WORKFLOW_OF_USER.UID.eq(USER.UID))
.select(USER.NAME)
.from(USER)
.join(WORKFLOW_OF_USER)
.on(USER.UID.eq(WORKFLOW_OF_USER.UID))
.where(WORKFLOW_OF_USER.WID.eq(wid))
.fetchOneInto(classOf[User])
.fetchOneInto(classOf[String])
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,23 @@ class WorkflowResourceSpec
)
}

"WorkflowResource /owner_name" should "return owner name as plain text" in {
workflowResource.persistWorkflow(testWorkflow1, sessionUser1)

val workflows = workflowResource.retrieveWorkflowsBySessionUser(sessionUser1)
assert(workflows.nonEmpty)

val wid =
workflows
.find(_.workflow.getName == testWorkflow1.getName)
.map(_.workflow.getWid)
.getOrElse(workflows.head.workflow.getWid)

val ownerName = workflowResource.getOwnerName(wid)

assert(ownerName == testUser.getName)
}

"/search API " should "be able to search for workflows in different columns in Workflow table" in {
// testWorkflow1: {name: test_name, descrption: test_description, content: test_content}
// search "test_name" or "test_description" or "test_content" should return testWorkflow1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const WORKFLOW_UPDATENAME_URL = WORKFLOW_BASE_URL + "/update/name";
export const WORKFLOW_UPDATEDESCRIPTION_URL = WORKFLOW_BASE_URL + "/update/description";
export const WORKFLOW_OWNER_URL = WORKFLOW_BASE_URL + "/user-workflow-owners";
export const WORKFLOW_ID_URL = WORKFLOW_BASE_URL + "/user-workflow-ids";
export const WORKFLOW_OWNER_USER = WORKFLOW_BASE_URL + "/owner_user";
export const WORKFLOW_OWNER_NAME = WORKFLOW_BASE_URL + "/owner_name";
export const WORKFLOW_NAME = WORKFLOW_BASE_URL + "/workflow_name";
export const WORKFLOW_PUBLIC_WORKFLOW = WORKFLOW_BASE_URL + "/publicised";
export const WORKFLOW_DESCRIPTION = WORKFLOW_BASE_URL + "/workflow_description";
Expand Down Expand Up @@ -238,13 +238,12 @@ export class WorkflowPersistService {
}

/**
* retrieve the complete information of the owner corresponding to the wid
* can be used without logging in
* @param wid
* Retrieve workflow owner name (no login required).
* @param wid workflow id
*/
public getOwnerUser(wid: number): Observable<User> {
public getOwnerName(wid: number): Observable<string> {
const params = new HttpParams().set("wid", wid);
return this.http.get<User>(`${AppSettings.getApiEndpoint()}/${WORKFLOW_OWNER_USER}`, { params });
return this.http.get(`${AppSettings.getApiEndpoint()}/${WORKFLOW_OWNER_NAME}`, { params, responseType: "text" });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export class HubWorkflowDetailComponent implements AfterViewInit, OnDestroy, OnI
this.viewCount = count;
});
this.workflowPersistService
.getOwnerUser(this.wid)
.getOwnerName(this.wid)
.pipe(untilDestroyed(this))
.subscribe(owner => {
this.ownerName = owner.name;
.subscribe(ownerName => {
this.ownerName = ownerName;
});
this.workflowPersistService
.getWorkflowName(this.wid)
Expand Down
Loading