Skip to content

Commit 21917bc

Browse files
authored
Merge pull request #250 from LabKey/fb_merge_25.3_to_develop
Merge 25.3 to develop
2 parents 7c730f6 + 67766a2 commit 21917bc

16 files changed

+643
-206
lines changed

LDK/src/org/labkey/ldk/LDKController.java

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -889,135 +889,6 @@ public void addNavTrail(NavTree root)
889889
}
890890
}
891891

892-
@RequiresPermission(AdminPermission.class)
893-
public static class MoveWorkbookAction extends ConfirmAction<MoveWorkbookForm>
894-
{
895-
private Container _movedWb = null;
896-
897-
@Override
898-
public void validateCommand(MoveWorkbookForm form, Errors errors)
899-
{
900-
901-
}
902-
903-
@Override
904-
public ModelAndView getConfirmView(MoveWorkbookForm form, BindException errors) throws Exception
905-
{
906-
if (!getContainer().isWorkbook())
907-
{
908-
errors.reject(ERROR_MSG, "This is only supported for workbooks");
909-
return new SimpleErrorView(errors);
910-
}
911-
912-
String sb = "This will move this workbook to the selected folder, renaming this workbook to match the series in that container. Note: there are many reasons this can be problematic, so please do this with great care<p>" +
913-
"<input name=\"targetContainer\" type=\"text\"></input>";
914-
915-
return new HtmlView(sb);
916-
}
917-
918-
@Override
919-
public boolean handlePost(MoveWorkbookForm form, BindException errors) throws Exception
920-
{
921-
Container toMove = getContainer();
922-
if (!toMove.isWorkbook())
923-
{
924-
errors.reject(ERROR_MSG, "This is only supported for workbooks");
925-
return false;
926-
}
927-
928-
if (StringUtils.trimToNull(form.getTargetContainer()) == null)
929-
{
930-
errors.reject(ERROR_MSG, "Must provide target container");
931-
return false;
932-
}
933-
934-
Container target = ContainerManager.getForPath(StringUtils.trimToNull(form.getTargetContainer()));
935-
if (target == null)
936-
{
937-
target = ContainerManager.getForId(StringUtils.trimToNull(form.getTargetContainer()));
938-
}
939-
940-
if (target == null)
941-
{
942-
errors.reject(ERROR_MSG, "Unknown container: " + form.getTargetContainer());
943-
return false;
944-
}
945-
946-
if (target.isWorkbook())
947-
{
948-
errors.reject(ERROR_MSG, "Target cannot be a workbook: " + form.getTargetContainer());
949-
return false;
950-
}
951-
952-
if (ContainerManager.isSystemContainer(target))
953-
{
954-
errors.reject(ERROR_MSG, "Cannot move to system containers: " + form.getTargetContainer());
955-
return false;
956-
}
957-
958-
if (target.equals(toMove.getParent()))
959-
{
960-
errors.reject(ERROR_MSG, "Cannot move the workbook to its current parent: " + form.getTargetContainer());
961-
return false;
962-
}
963-
964-
//NOTE: transaction causing problems for larger sites?
965-
//try (DbScope.Transaction transaction = CoreSchema.getInstance().getSchema().getScope().ensureTransaction())
966-
//{
967-
//first rename workbook to make unique
968-
String tempName = new GUID().toString();
969-
int sortOrder = (int)DbSequenceManager.get(target, ContainerManager.WORKBOOK_DBSEQUENCE_NAME).next();
970-
_log.info("renaming workbook to in preparation for move from: " + toMove.getPath() + " to: " + tempName);
971-
ContainerManager.rename(toMove, getUser(), tempName);
972-
toMove = ContainerManager.getForId(toMove.getId());
973-
974-
//then move parent
975-
_log.info("moving workbook from: " + toMove.getPath() + " to: " + target.getPath());
976-
ContainerManager.move(toMove, target, getUser());
977-
toMove = ContainerManager.getForId(toMove.getId());
978-
979-
//finally move to correct name
980-
_log.info("renaming workbook from: " + toMove.getPath() + " to: " + sortOrder);
981-
ContainerManager.rename(toMove, getUser(), String.valueOf(sortOrder));
982-
toMove.setSortOrder(sortOrder);
983-
new SqlExecutor(CoreSchema.getInstance().getSchema()).execute("UPDATE core.containers SET SortOrder = ? WHERE EntityId = ?", toMove.getSortOrder(), toMove.getId());
984-
toMove = ContainerManager.getForId(toMove.getId());
985-
986-
//transaction.commit();
987-
_log.info("workbook move finished");
988-
989-
_movedWb = toMove;
990-
//}
991-
992-
return true;
993-
}
994-
995-
@NotNull
996-
@Override
997-
public URLHelper getSuccessURL(MoveWorkbookForm moveWorkbookForm)
998-
{
999-
if (_movedWb == null)
1000-
return getContainer().getStartURL(getUser());
1001-
else
1002-
return _movedWb.getStartURL(getUser());
1003-
}
1004-
}
1005-
1006-
public static class MoveWorkbookForm
1007-
{
1008-
private String _targetContainer;
1009-
1010-
public String getTargetContainer()
1011-
{
1012-
return _targetContainer;
1013-
}
1014-
1015-
public void setTargetContainer(String targetContainer)
1016-
{
1017-
_targetContainer = targetContainer;
1018-
}
1019-
}
1020-
1021892
@RequiresNoPermission
1022893
public static class RedirectStartAction extends SimpleViewAction<Object>
1023894
{

LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,24 @@ private void setDetailsUrl(AbstractTableInfo ti)
125125

126126
List<String> keyFields = ti.getPkColumnNames();
127127
assert !keyFields.isEmpty() : "No key fields found for the table: " + ti.getPublicSchemaName() + "." + ti.getPublicName();
128-
if (keyFields.size() != 1)
128+
129+
if (_settings.getPrimaryKeyField() != null)
130+
{
131+
String alternatePK = _settings.getPrimaryKeyField();
132+
if (!keyFields.contains(alternatePK))
133+
{
134+
_log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " supplied an alternate primaryKeyField that doesnt match actual PKs: " + alternatePK);
135+
return;
136+
}
137+
138+
keyFields = Collections.singletonList(alternatePK);
139+
}
140+
141+
if (keyFields.isEmpty())
142+
{
143+
return;
144+
}
145+
else if (keyFields.size() > 1)
129146
{
130147
_log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " has more than 1 PK: " + StringUtils.join(keyFields, ";") + ", cannot apply custom links - please update the TableCustomizer properties");
131148
return;
@@ -159,13 +176,30 @@ else if (_settings.isSetEditLinkOverrides())
159176

160177
List<String> keyFields = ti.getPkColumnNames();
161178
assert !keyFields.isEmpty() : "No key fields found for the table: " + ti.getPublicSchemaName() + "." + ti.getPublicName();
162-
if (keyFields.size() != 1)
179+
180+
if (_settings.getPrimaryKeyField() != null)
181+
{
182+
String alternatePK = _settings.getPrimaryKeyField();
183+
if (!keyFields.contains(alternatePK))
184+
{
185+
_log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " supplied an alternate primaryKeyField that doesnt match actual PKs: " + alternatePK);
186+
return;
187+
}
188+
189+
keyFields = Collections.singletonList(alternatePK);
190+
}
191+
192+
if (keyFields.isEmpty())
193+
{
194+
return;
195+
}
196+
else if (keyFields.size() != 1)
163197
{
164198
_log.error("Table: " + schemaName + "." + queryName + " has more than 1 PK: " + StringUtils.join(keyFields, ";") + ", cannot apply custom links - please update the TableCustomizer properties");
165199
return;
166200
}
167201

168-
if (schemaName != null && queryName != null && !keyFields.isEmpty())
202+
if (schemaName != null && queryName != null)
169203
{
170204
String keyField = keyFields.get(0);
171205
if (!AbstractTableInfo.LINK_DISABLER_ACTION_URL.equals(ti.getImportDataURL(ti.getUserSchema().getContainer())))
@@ -444,7 +478,8 @@ public enum PROPERIES
444478
setEditLinkOverrides(Boolean.class, true),
445479
auditMode(String.class, AuditBehaviorType.DETAILED.name()),
446480
disableFacetingForNumericCols(Boolean.class, true),
447-
overrideDetailsUrl(Boolean.class, true);
481+
overrideDetailsUrl(Boolean.class, true),
482+
primaryKeyField(String.class, null);
448483

449484
private final Class _clazz;
450485
private final Object _defaultVal;
@@ -530,6 +565,17 @@ public AuditBehaviorType getAuditMode()
530565
return AuditBehaviorType.DETAILED;
531566
}
532567

568+
public String getPrimaryKeyField()
569+
{
570+
Object fieldName = getProperty(PROPERIES.primaryKeyField);
571+
if (fieldName != null)
572+
{
573+
return fieldName.toString();
574+
}
575+
576+
return null;
577+
}
578+
533579
public boolean isDisableFacetingForNumericCols()
534580
{
535581
return (boolean)getProperty(PROPERIES.disableFacetingForNumericCols);

laboratory/api-src/org/labkey/api/laboratory/LaboratoryService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.labkey.api.exp.api.ExpProtocol;
2727
import org.labkey.api.exp.api.ExpRun;
2828
import org.labkey.api.laboratory.assay.AssayDataProvider;
29+
import org.labkey.api.laboratory.query.TabbedReportFilterProvider;
2930
import org.labkey.api.ldk.table.ButtonConfigFactory;
3031
import org.labkey.api.module.Module;
3132
import org.labkey.api.query.ValidationException;
@@ -123,7 +124,13 @@ static public void setInstance(LaboratoryService instance)
123124

124125
abstract public @Nullable DemographicsProvider getDemographicsProviderByName(Container c, User u, String name);
125126

126-
public enum NavItemCategory
127+
abstract public void clearDataProviderCache();
128+
129+
abstract public void registerTabbedReportFilterProvider(TabbedReportFilterProvider provider);
130+
131+
abstract public List<TabbedReportFilterProvider> getTabbedReportFilterProviderProviders(final Container c, final User u);
132+
133+
public static enum NavItemCategory
127134
{
128135
samples(),
129136
misc(),

laboratory/api-src/org/labkey/api/laboratory/QueryTabbedReportItem.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class QueryTabbedReportItem extends TabbedReportItem
3030
{
3131
private String _schemaName;
3232
private String _queryName;
33+
private String _viewName;
3334

3435
public QueryTabbedReportItem(QueryCache cache, DataProvider provider, String schemaName, String queryName, String label, String reportCategory)
3536
{
@@ -67,6 +68,16 @@ public void setQueryName(String queryName)
6768
_queryName = queryName;
6869
}
6970

71+
public String getViewName()
72+
{
73+
return _viewName;
74+
}
75+
76+
public void setViewName(String viewName)
77+
{
78+
_viewName = viewName;
79+
}
80+
7081
@Override
7182
public JSONObject toJSON(Container c, User u)
7283
{
@@ -77,12 +88,18 @@ public JSONObject toJSON(Container c, User u)
7788
return null;
7889
}
7990

80-
inferColumnsFromTable(ti);
91+
inferColumnsFromTable(ti, c, u);
8192
JSONObject json = super.toJSON(c, u);
8293

8394
json.put("schemaName", getSchemaName());
8495
json.put("queryName", getQueryName());
8596
String viewName = getDefaultViewName(c, getOwnerKey());
97+
98+
if (getViewName() != null)
99+
{
100+
viewName = getViewName();
101+
}
102+
86103
if (viewName != null)
87104
{
88105
json.put("viewName", viewName);

0 commit comments

Comments
 (0)