Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions announcements/src/org/labkey/announcements/AnnouncementModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,20 @@
import org.labkey.api.attachments.AttachmentParentType;
import org.labkey.api.audit.AuditLogService;
import org.labkey.api.audit.provider.MessageAuditProvider;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SqlExecutor;
import org.labkey.api.data.TableInfo;
import org.labkey.api.data.WrappedColumn;
import org.labkey.api.message.digest.DailyMessageDigest;
import org.labkey.api.message.settings.MessageConfigService;
import org.labkey.api.migration.DatabaseMigrationConfiguration;
import org.labkey.api.migration.DatabaseMigrationService;
import org.labkey.api.migration.DefaultMigrationSchemaHandler;
import org.labkey.api.migration.MigrationTableHandler;
import org.labkey.api.module.DefaultModule;
import org.labkey.api.module.ModuleContext;
import org.labkey.api.rss.RSSService;
Expand All @@ -52,6 +56,7 @@
import org.labkey.api.security.roles.EditorRole;
import org.labkey.api.security.roles.Role;
import org.labkey.api.security.roles.RoleManager;
import org.labkey.api.util.GUID;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.emailTemplate.EmailTemplateService;
import org.labkey.api.view.AlwaysAvailableWebPartFactory;
Expand Down Expand Up @@ -208,6 +213,45 @@ public void afterSchema(DatabaseMigrationConfiguration configuration, DbSchema s
return ws != null ? List.of(AnnouncementType.get(), ws.getAttachmentType()) : List.of(AnnouncementType.get());
}
});

DatabaseMigrationService.get().registerTableHandler(new MigrationTableHandler()
{
@Override
public TableInfo getTableInfo()
{
return CommSchema.getInstance().getTableInfoAnnouncements();
}

@Override
public ColumnInfo handleColumn(ColumnInfo col)
{
return "DiscussionSrcIdentifier".equals(col.getName()) ? new GuidMapperColumn(col) : col;
}

// In this column, map any value that exactly matches a GUID to lowercase
private static final class GuidMapperColumn extends WrappedColumn
{
public GuidMapperColumn(ColumnInfo col)
{
super(col, col.getName());
}

@Override
public SQLFragment getValueSql(String tableAlias)
{
SQLFragment columnAlias = super.getValueSql(tableAlias);
//noinspection StringConcatenationInsideStringBufferAppend - SQLFragment flips out about unmatched quotes, so we're forced to use string concatenation
return new SQLFragment("CASE WHEN ")
.append(columnAlias)
.append(" LIKE '" + GUID.SQL_LIKE_GUID_PATTERN + "'")
.append(" THEN LOWER(")
.append(columnAlias)
.append(") ELSE ")
.append(columnAlias)
.append(" END");
}
}
});
}


Expand Down
8 changes: 5 additions & 3 deletions api/src/org/labkey/api/ApiModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public void registerServlets(ServletContext servletCtx)
Aggregate.TestCase.class,
ApiXmlWriter.TestCase.class,
ArrayListMap.TestCase.class,
AssayResultsFileWriter.TestCase.class,
BaseServerProperties.TestCase.class,
BooleanFormat.TestCase.class,
BuilderObjectFactory.TestCase.class,
Expand Down Expand Up @@ -399,12 +400,12 @@ public void registerServlets(ServletContext servletCtx)
GenerateUniqueDataIterator.TestCase.class,
HelpTopic.TestCase.class,
InlineInClauseGenerator.TestCase.class,
JobRunner.TestCase.class,
JSONDataLoader.HeaderMatchTest.class,
JSONDataLoader.MetadataTest.class,
JSONDataLoader.RowTest.class,
JSoupUtil.TestCase.class,
JavaVersion.TestCase.class,
JobRunner.TestCase.class,
JsonTest.class,
JsonUtil.TestCase.class,
LimitedUser.TestCase.class,
Expand All @@ -429,8 +430,10 @@ public void registerServlets(ServletContext servletCtx)
SchemaKey.TestCase.class,
SessionHelper.TestCase.class,
SimpleFilter.BetweenClauseTestCase.class,
SimpleFilter.ContainsOneOfTestCase.class,
SimpleFilter.FilterTestCase.class,
SimpleFilter.InClauseTestCase.class,
SimpleFilter.SqlClauseTestCase.class,
SqlScanner.TestCase.class,
StringExpressionFactory.TestCase.class,
StringUtilsLabKey.TestCase.class,
Expand All @@ -440,9 +443,8 @@ public void registerServlets(ServletContext servletCtx)
TSVWriter.TestCase.class,
TabLoader.HeaderMatchTest.class,
Table.IsSelectTestCase.class,
ValidEmail.TestCase.class,
URIUtil.TestCase.class,
AssayResultsFileWriter.TestCase.class
ValidEmail.TestCase.class
);
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/data/CompareType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,7 @@ SQLFragment toWhereClause(SqlDialect dialect, DatabaseIdentifier alias)
public String getLabKeySQLWhereClause(Map<FieldKey, ? extends ColumnInfo> columnMap)
{
String colName = getLabKeySQLColName(_fieldKey);
return "LOWER(" + colName + ") LIKE LOWER('%" + escapeLabKeySqlValue(getParamVals()[0], getColumnType(columnMap, JdbcType.VARCHAR), true) + "%') " + sqlEscape();
return "LOWER(" + colName + ") LIKE LOWER('%" + escapeLabKeySqlValue(getParamVals()[0], getColumnType(columnMap, JdbcType.VARCHAR), true) + "%')" + sqlEscape();
}

@Override
Expand Down
11 changes: 10 additions & 1 deletion api/src/org/labkey/api/data/SQLFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,15 @@ public String toString()
return "SQLFragment@" + System.identityHashCode(this) + "\n" + JdbcUtil.format(this);
}


public String toDebugString()
{
return JdbcUtil.format(this);
}

public String toDebugString(SqlDialect dialect)
{
return JdbcUtil.format(this, dialect);
}

public List<Object> getParams()
{
Expand Down Expand Up @@ -1322,6 +1325,12 @@ public boolean equals(Object obj)
return getSQL().equals(other.getSQL()) && getParams().equals(other.getParams());
}

@Override
public int hashCode()
{
return Objects.hash(getSQL(), getParams());
}

/**
* Joins the SQLFragments in the provided {@code Iterable} into a single SQLFragment. The SQL is joined by string
* concatenation using the provided separator. The parameters are combined to form the new parameter list.
Expand Down
Loading