Skip to content

Commit bdf7698

Browse files
committed
LL-828
1 parent 9a299a8 commit bdf7698

File tree

18 files changed

+1997
-1817
lines changed

18 files changed

+1997
-1817
lines changed

serv/serv-serv/serv-caller/src/main/java/at/kc/tugraz/ss/serv/serv/caller/SSServCaller.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,16 +1355,18 @@ public static List<SSUri> entityFilesGet(
13551355
return (List<SSUri>) SSServA.callServViaServer(new SSServPar(SSMethU.entityFilesGet, opPars));
13561356
}
13571357

1358-
public static List<? extends SSEntity> videosGet(
1358+
public static List<? extends SSEntity> videosUserGet(
13591359
final SSUri user,
1360+
final SSUri forUser,
13601361
final SSUri forEntity) throws Exception{
13611362

13621363
final Map<String, Object> opPars = new HashMap<>();
13631364

13641365
opPars.put(SSVarU.user, user);
1366+
opPars.put(SSVarU.forUser, forUser);
13651367
opPars.put(SSVarU.forEntity, forEntity);
13661368

1367-
return (List<? extends SSEntity>) SSServA.callServViaServer(new SSServPar(SSMethU.videosGet, opPars));
1369+
return (List<? extends SSEntity>) SSServA.callServViaServer(new SSServPar(SSMethU.videosUserGet, opPars));
13681370
}
13691371

13701372
public static List<SSUri> entityDownloadURIsGet(
@@ -2841,15 +2843,15 @@ public static List<SSActivity> activitiesUserGet(
28412843
/* video */
28422844
public static SSUri videoUserAdd(
28432845
final SSUri user,
2844-
final SSUri video,
2846+
final SSUri link,
28452847
final SSUri forEntity,
28462848
final Boolean shouldCommit) throws Exception{
28472849

28482850
final Map<String, Object> opPars = new HashMap<>();
28492851

28502852
opPars.put(SSVarU.shouldCommit, shouldCommit);
28512853
opPars.put(SSVarU.user, user);
2852-
opPars.put(SSVarU.video, video);
2854+
opPars.put(SSVarU.link, link);
28532855
opPars.put(SSVarU.forEntity, forEntity);
28542856

28552857
return (SSUri) SSServA.callServViaServer(new SSServPar(SSMethU.videoUserAdd, opPars));

serv/ss-datatypes/app/app.impl/src/main/java/at/kc/tugraz/sss/app/impl/SSAppImpl.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,6 @@ public SSUri appAdd(final SSServPar parA) throws Exception{
139139
false);
140140
}
141141

142-
// for(SSUri video : par.videos){
143-
//
144-
//// SSServCaller.entityEntityToPubCircleAdd(
145-
//// par.user,
146-
//// video,
147-
//// SSEntityE.video,
148-
//// null,
149-
//// null,
150-
//// null,
151-
//// false);
152-
// }
153-
154142
SSServCaller.entityUpdate(
155143
par.user,
156144
appUri,
@@ -233,8 +221,9 @@ public List<SSApp> appsGet(final SSServPar parA) throws Exception{
233221
try{
234222

235223
entity.attachedEntities.addAll(
236-
SSServCaller.videosGet(
224+
SSServCaller.videosUserGet(
237225
par.user,
226+
null,
238227
app.id));
239228

240229
}catch(SSErr error){

serv/ss-datatypes/ss-entity/ss-entity-impl/src/main/java/at/kc/tugraz/ss/serv/datatypes/entity/impl/SSEntityImpl.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import at.kc.tugraz.ss.serv.err.reg.SSServErrReg;
4444
import at.kc.tugraz.ss.datatypes.datatypes.SSEntityCircle;
4545
import at.kc.tugraz.ss.datatypes.datatypes.SSImage;
46+
import at.kc.tugraz.ss.datatypes.datatypes.SSImageE;
4647
import at.kc.tugraz.ss.datatypes.datatypes.SSLocation;
4748
import at.kc.tugraz.ss.serv.datatypes.entity.datatypes.par.SSEntitiesForDescriptionsGetPar;
4849
import at.kc.tugraz.ss.serv.datatypes.entity.datatypes.par.SSEntitiesForLabelsAndDescriptionsGetPar;
@@ -421,15 +422,25 @@ public SSUri entityUpdate(final SSServPar parA) throws Exception{
421422
null);
422423

423424
for(SSUri screenShot : par.screenShots){
424-
sqlFct.addScreenShot (par.entity, screenShot);
425+
426+
sqlFct.addImage(
427+
screenShot,
428+
SSImageE.screenShot);
429+
430+
sqlFct.attachEntity(par.entity, screenShot);
425431
}
426432

427433
for(SSUri download : par.downloads){
428434
sqlFct.addDownload (par.entity, download);
429435
}
430436

431437
for(SSUri image : par.images){
432-
sqlFct.addImage (par.entity, image);
438+
439+
sqlFct.addImage(
440+
image,
441+
SSImageE.image);
442+
443+
sqlFct.attachEntity(par.entity, image);
433444
}
434445

435446
SSEntityMiscFct.updateEntityByEntityHandlers(par);
@@ -1837,7 +1848,11 @@ public List<SSImage> entityScreenShotsGet(SSServPar parA) throws Exception{
18371848
try{
18381849
final SSEntityScreenShotsGetPar par = new SSEntityScreenShotsGetPar(parA);
18391850

1840-
return SSImage.get(sqlFct.getScreenShots(par.entity));
1851+
return
1852+
SSImage.get(
1853+
sqlFct.getImages(
1854+
par.entity,
1855+
SSImageE.screenShot));
18411856

18421857
}catch(Exception error){
18431858
SSServErrReg.regErrThrow(error);

serv/ss-datatypes/ss-entity/ss-entity-impl/src/main/java/at/kc/tugraz/ss/serv/datatypes/entity/impl/fct/sql/SSEntitySQLFct.java

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import at.kc.tugraz.ss.datatypes.datatypes.SSEntity;
3535
import at.kc.tugraz.ss.serv.err.reg.SSServErrReg;
3636
import at.kc.tugraz.ss.datatypes.datatypes.SSEntityCircle;
37+
import at.kc.tugraz.ss.datatypes.datatypes.SSImageE;
3738
import at.kc.tugraz.ss.datatypes.datatypes.SSLocation;
3839
import at.kc.tugraz.ss.serv.datatypes.entity.impl.fct.op.SSEntityMiscFct;
3940
import at.kc.tugraz.ss.serv.serv.api.SSServImplWithDBA;
@@ -394,11 +395,15 @@ public void attachEntity(
394395
try{
395396

396397
final Map<String, String> inserts = new HashMap<>();
398+
final Map<String, String> uniqueKeys = new HashMap<>();
397399

398400
insert(inserts, SSSQLVarU.entityId, entity);
399401
insert(inserts, SSSQLVarU.attachedEntityId, entityToAttach);
400402

401-
dbSQL.insert(entitiesTable, inserts);
403+
uniqueKey(uniqueKeys, SSSQLVarU.entityId, entity);
404+
uniqueKey(uniqueKeys, SSSQLVarU.attachedEntityId, entityToAttach);
405+
406+
dbSQL.insertIfNotExists(entitiesTable, inserts, uniqueKeys);
402407

403408
}catch(Exception error){
404409
SSServErrReg.regErrThrow(error);
@@ -775,19 +780,43 @@ public List<SSUri> getThumbs(final SSUri entity) throws Exception{
775780
}
776781
}
777782

778-
public List<SSUri> getScreenShots(final SSUri entity) throws Exception{
783+
public List<SSUri> getImages(
784+
final SSUri forEntity,
785+
final SSImageE type) throws Exception{
779786

780787
ResultSet resultSet = null;
781788

782789
try{
790+
final List<String> columns = new ArrayList<>();
791+
final List<String> tables = new ArrayList<>();
792+
final Map<String, String> wheres = new HashMap<>();
793+
final List<String> tableCons = new ArrayList<>();
783794

784-
final Map<String, String> wheres = new HashMap<>();
795+
column (columns, imageTable, SSSQLVarU.imageId);
796+
table (tables, imageTable);
785797

786-
where(wheres, SSSQLVarU.entityId, entity);
798+
if(forEntity != null){
799+
where (wheres, entitiesTable, SSSQLVarU.entityId, forEntity);
800+
table (tables, entitiesTable);
801+
tableCon(tableCons, imageTable, SSSQLVarU.imageId, entitiesTable, SSSQLVarU.attachedEntityId);
802+
}
787803

788-
resultSet = dbSQL.select(screenShotsTable, wheres);
804+
if(type != null){
805+
where(wheres, imageTable, SSSQLVarU.type, type);
806+
}
807+
808+
if(wheres.isEmpty()){
809+
resultSet = dbSQL.select(imageTable);
810+
}else{
811+
812+
if(tableCons.isEmpty()){
813+
resultSet = dbSQL.select(imageTable, columns, wheres);
814+
}else{
815+
resultSet = dbSQL.select(tables, columns, wheres, tableCons);
816+
}
817+
}
789818

790-
return getURIsFromResult(resultSet, SSSQLVarU.screenShotId);
819+
return getURIsFromResult(resultSet, SSSQLVarU.imageId);
791820

792821
}catch(Exception error){
793822
SSServErrReg.regErrThrow(error);
@@ -1354,44 +1383,43 @@ public void addDownload(
13541383
}
13551384
}
13561385

1357-
public void addImage(
1358-
final SSUri entity,
1359-
final SSUri image) throws Exception{
1360-
1361-
try{
1362-
1363-
final Map<String, String> inserts = new HashMap<>();
1364-
final Map<String, String> uniqueKeys = new HashMap<>();
1365-
1366-
insert(inserts, SSSQLVarU.entityId, entity);
1367-
insert(inserts, SSSQLVarU.imageId, image);
1368-
1369-
uniqueKey(uniqueKeys, SSSQLVarU.entityId, entity);
1370-
uniqueKey(uniqueKeys, SSSQLVarU.imageId, image);
1371-
1372-
dbSQL.insertIfNotExists(entityImagesTable, inserts, uniqueKeys);
1373-
1374-
}catch(Exception error){
1375-
SSServErrReg.regErrThrow(error);
1376-
}
1377-
}
1386+
// public void addImage(
1387+
// final SSUri entity,
1388+
// final SSUri image) throws Exception{
1389+
//
1390+
// try{
1391+
//
1392+
// final Map<String, String> inserts = new HashMap<>();
1393+
// final Map<String, String> uniqueKeys = new HashMap<>();
1394+
//
1395+
// insert(inserts, SSSQLVarU.entityId, entity);
1396+
// insert(inserts, SSSQLVarU.imageId, image);
1397+
//
1398+
// uniqueKey(uniqueKeys, SSSQLVarU.entityId, entity);
1399+
// uniqueKey(uniqueKeys, SSSQLVarU.imageId, image);
1400+
//
1401+
// dbSQL.insertIfNotExists(entityImagesTable, inserts, uniqueKeys);
1402+
//
1403+
// }catch(Exception error){
1404+
// SSServErrReg.regErrThrow(error);
1405+
// }
1406+
// }
13781407

1379-
public void addScreenShot(
1380-
final SSUri entity,
1381-
final SSUri screenShot) throws Exception{
1408+
public void addImage(
1409+
final SSUri image,
1410+
final SSImageE type) throws Exception{
13821411

13831412
try{
13841413

13851414
final Map<String, String> inserts = new HashMap<>();
13861415
final Map<String, String> uniqueKeys = new HashMap<>();
13871416

1388-
insert(inserts, SSSQLVarU.entityId, entity);
1389-
insert(inserts, SSSQLVarU.screenShotId, screenShot);
1417+
insert(inserts, SSSQLVarU.imageId, image);
1418+
insert(inserts, SSSQLVarU.type, type);
13901419

1391-
uniqueKey(uniqueKeys, SSSQLVarU.entityId, entity);
1392-
uniqueKey(uniqueKeys, SSSQLVarU.screenShotId, screenShot);
1420+
uniqueKey(uniqueKeys, SSSQLVarU.imageId, image);
13931421

1394-
dbSQL.insertIfNotExists(screenShotsTable, inserts, uniqueKeys);
1422+
dbSQL.insertIfNotExists(imageTable, inserts, uniqueKeys);
13951423

13961424
}catch(Exception error){
13971425
SSServErrReg.regErrThrow(error);

serv/ss-datatypes/video/video.datatypes/src/main/java/at/kc/tugraz/sss/video/datatypes/par/SSVideoUserAddPar.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
2+
/**
23
* Code contributed to the Learning Layers project
34
* http://www.learning-layers.eu
45
* Development is partly funded by the FP7 Programme of the European Commission under
@@ -39,9 +40,19 @@ public class SSVideoUserAddPar extends SSServPar{
3940
@XmlElement
4041
@ApiModelProperty(
4142
required = false,
42-
value = "video's uuid (if provided used within id)")
43+
value = "video's uuid (if provided used within id if link is not set)")
4344
public String uuid = null;
4445

46+
@ApiModelProperty(
47+
required = false,
48+
value = "video's link (if provided used as id)")
49+
public SSUri link = null;
50+
51+
@XmlElement
52+
public void setLink(final String link) throws Exception{
53+
this.link = SSUri.get(link);
54+
}
55+
4556
@ApiModelProperty(
4657
required = false,
4758
value = "entity for which to attach this video")
@@ -113,6 +124,7 @@ public SSVideoUserAddPar(SSServPar par) throws Exception{
113124
if(pars != null){
114125

115126
uuid = (String) pars.get(SSVarU.uuid);
127+
link = (SSUri) pars.get(SSVarU.link);
116128
forEntity = (SSUri) pars.get(SSVarU.forEntity);
117129
genre = (String) pars.get(SSVarU.genre);
118130
label = (SSLabel) pars.get(SSVarU.label);
@@ -129,6 +141,10 @@ public SSVideoUserAddPar(SSServPar par) throws Exception{
129141
uuid = par.clientJSONObj.get(SSVarU.app).getTextValue();
130142
}catch(Exception error){}
131143

144+
try{
145+
link = SSUri.get(par.clientJSONObj.get(SSVarU.link).getTextValue());
146+
}catch(Exception error){}
147+
132148
try{
133149
forEntity = SSUri.get(par.clientJSONObj.get(SSVarU.forEntity).getTextValue());
134150
}catch(Exception error){}
@@ -172,6 +188,10 @@ public String getForEntity(){
172188
return SSStrU.removeTrailingSlash(forEntity);
173189
}
174190

191+
public String getLink(){
192+
return SSStrU.removeTrailingSlash(link);
193+
}
194+
175195
public String getLabel(){
176196
return SSStrU.toStr(label);
177197
}

serv/ss-datatypes/video/video.datatypes/src/main/java/at/kc/tugraz/sss/video/datatypes/par/SSVideosUserGetPar.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,26 @@
3434
@ApiModel(value = "videosGet request parameter")
3535
public class SSVideosUserGetPar extends SSServPar{
3636

37-
@XmlElement
3837
@ApiModelProperty(
3938
required = false,
4039
value = "entity to get videos for")
4140
public SSUri forEntity = null;
4241

42+
@XmlElement
43+
public void setForEntity(final String forEntity) throws Exception{
44+
this.forEntity = SSUri.get(forEntity);
45+
}
46+
47+
@ApiModelProperty(
48+
required = false,
49+
value = "user to get videos for")
50+
public SSUri forUser = null;
51+
52+
@XmlElement
53+
public void setForUser(final String forUser) throws Exception{
54+
this.forUser = SSUri.get(forUser);
55+
}
56+
4357
public SSVideosUserGetPar(){}
4458

4559
public SSVideosUserGetPar(SSServPar par) throws Exception{
@@ -49,9 +63,15 @@ public SSVideosUserGetPar(SSServPar par) throws Exception{
4963

5064
if(pars != null){
5165
forEntity = (SSUri) pars.get(SSVarU.forEntity);
66+
forUser = (SSUri) pars.get(SSVarU.forUser);
5267
}
5368

5469
if(par.clientJSONObj != null){
70+
71+
try{
72+
forUser = SSUri.get (par.clientJSONObj.get(SSVarU.forUser).getTextValue());
73+
}catch(Exception error){}
74+
5575
try{
5676
forEntity = SSUri.get (par.clientJSONObj.get(SSVarU.forEntity).getTextValue());
5777
}catch(Exception error){}
@@ -65,4 +85,8 @@ public SSVideosUserGetPar(SSServPar par) throws Exception{
6585
public String getForEntity(){
6686
return SSStrU.removeTrailingSlash(forEntity);
6787
}
88+
89+
public String getForUser(){
90+
return SSStrU.removeTrailingSlash(forUser);
91+
}
6892
}

0 commit comments

Comments
 (0)