Skip to content

Commit

Permalink
Added new features / Bug fixed
Browse files Browse the repository at this point in the history
・サーバスクリプトにUpsertメソッドを追加。
・サイト統合されたテーブルのデータをサーバスクリプトで取得する機能を追加。
・サイト統合されたテーブルのデータをAPIで取得する機能を追加。
  • Loading branch information
uchi-ta committed Jul 11, 2023
1 parent d3f048a commit 6b341fb
Show file tree
Hide file tree
Showing 24 changed files with 538 additions and 104 deletions.
6 changes: 3 additions & 3 deletions Implem.CodeDefiner/Implem.CodeDefiner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<Description>This program does the automatic code creation and merging of existing code based on the definition. Also it will make the configuration change of sql server database.</Description>
<AssemblyVersion>1.3.42.1</AssemblyVersion>
<FileVersion>1.3.42.1</FileVersion>
<Version>1.3.42.1</Version>
<AssemblyVersion>1.3.43.0</AssemblyVersion>
<FileVersion>1.3.43.0</FileVersion>
<Version>1.3.43.0</Version>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

Expand Down
6 changes: 6 additions & 0 deletions Implem.DefinitionAccessor/Def.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ public static void SetCodeDefinition()
case "Model_UpdateTitles": Code.Model_UpdateTitles = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateTitles, definitionRow, CodeXls); break;
case "Model_UpdateWikiTitle": Code.Model_UpdateWikiTitle = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateWikiTitle, definitionRow, CodeXls); break;
case "Model_UpsertByApiCases": Code.Model_UpsertByApiCases = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpsertByApiCases, definitionRow, CodeXls); break;
case "Model_UpsertByServerScriptCases": Code.Model_UpsertByServerScriptCases = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpsertByServerScriptCases, definitionRow, CodeXls); break;
case "Model_Utilities": Code.Model_Utilities = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities, definitionRow, CodeXls); break;
case "Model_Utilities_ApiCreatedMessage": Code.Model_Utilities_ApiCreatedMessage = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_ApiCreatedMessage, definitionRow, CodeXls); break;
case "Model_Utilities_ApiCreatedMessage_Table": Code.Model_Utilities_ApiCreatedMessage_Table = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_ApiCreatedMessage_Table, definitionRow, CodeXls); break;
Expand Down Expand Up @@ -902,6 +903,7 @@ public static void SetCodeDefinition()
case "Model_Utilities_UpdateNotItems": Code.Model_Utilities_UpdateNotItems = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_UpdateNotItems, definitionRow, CodeXls); break;
case "Model_Utilities_UpdateParameters_Sites": Code.Model_Utilities_UpdateParameters_Sites = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_UpdateParameters_Sites, definitionRow, CodeXls); break;
case "Model_Utilities_UpsertByApi": Code.Model_Utilities_UpsertByApi = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_UpsertByApi, definitionRow, CodeXls); break;
case "Model_Utilities_UpsertByServerScript": Code.Model_Utilities_UpsertByServerScript = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_UpsertByServerScript, definitionRow, CodeXls); break;
case "Model_Utilities_ViewSelectorField": Code.Model_Utilities_ViewSelectorField = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_ViewSelectorField, definitionRow, CodeXls); break;
case "Model_Utilities_ViewSelectorFieldWithShowHistory": Code.Model_Utilities_ViewSelectorFieldWithShowHistory = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_ViewSelectorFieldWithShowHistory, definitionRow, CodeXls); break;
case "Model_Utilities_WhereTenantId": Code.Model_Utilities_WhereTenantId = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Utilities_WhereTenantId, definitionRow, CodeXls); break;
Expand Down Expand Up @@ -7143,6 +7145,7 @@ public class CodeColumn2nd
public string Model_UpdateTitles;
public string Model_UpdateWikiTitle;
public string Model_UpsertByApiCases;
public string Model_UpsertByServerScriptCases;
public string Model_Utilities;
public string Model_Utilities_ApiCreatedMessage;
public string Model_Utilities_ApiCreatedMessage_Table;
Expand Down Expand Up @@ -7326,6 +7329,7 @@ public class CodeColumn2nd
public string Model_Utilities_UpdateNotItems;
public string Model_Utilities_UpdateParameters_Sites;
public string Model_Utilities_UpsertByApi;
public string Model_Utilities_UpsertByServerScript;
public string Model_Utilities_ViewSelectorField;
public string Model_Utilities_ViewSelectorFieldWithShowHistory;
public string Model_Utilities_WhereTenantId;
Expand Down Expand Up @@ -7935,6 +7939,7 @@ public class CodeTable
public CodeDefinition Model_UpdateTitles = new CodeDefinition();
public CodeDefinition Model_UpdateWikiTitle = new CodeDefinition();
public CodeDefinition Model_UpsertByApiCases = new CodeDefinition();
public CodeDefinition Model_UpsertByServerScriptCases = new CodeDefinition();
public CodeDefinition Model_Utilities = new CodeDefinition();
public CodeDefinition Model_Utilities_ApiCreatedMessage = new CodeDefinition();
public CodeDefinition Model_Utilities_ApiCreatedMessage_Table = new CodeDefinition();
Expand Down Expand Up @@ -8118,6 +8123,7 @@ public class CodeTable
public CodeDefinition Model_Utilities_UpdateNotItems = new CodeDefinition();
public CodeDefinition Model_Utilities_UpdateParameters_Sites = new CodeDefinition();
public CodeDefinition Model_Utilities_UpsertByApi = new CodeDefinition();
public CodeDefinition Model_Utilities_UpsertByServerScript = new CodeDefinition();
public CodeDefinition Model_Utilities_ViewSelectorField = new CodeDefinition();
public CodeDefinition Model_Utilities_ViewSelectorFieldWithShowHistory = new CodeDefinition();
public CodeDefinition Model_Utilities_WhereTenantId = new CodeDefinition();
Expand Down
6 changes: 3 additions & 3 deletions Implem.DefinitionAccessor/Implem.DefinitionAccessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.42.1</AssemblyVersion>
<FileVersion>1.3.42.1</FileVersion>
<Version>1.3.42.1</Version>
<AssemblyVersion>1.3.43.0</AssemblyVersion>
<FileVersion>1.3.43.0</FileVersion>
<Version>1.3.43.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.DisplayAccessor/Implem.DisplayAccessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.42.1</AssemblyVersion>
<FileVersion>1.3.42.1</FileVersion>
<Version>1.3.42.1</Version>
<AssemblyVersion>1.3.43.0</AssemblyVersion>
<FileVersion>1.3.43.0</FileVersion>
<Version>1.3.43.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.Factory/Implem.Factory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.42.1</AssemblyVersion>
<FileVersion>1.3.42.1</FileVersion>
<Version>1.3.42.1</Version>
<AssemblyVersion>1.3.43.0</AssemblyVersion>
<FileVersion>1.3.43.0</FileVersion>
<Version>1.3.43.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.Libraries/Implem.Libraries.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.42.1</AssemblyVersion>
<FileVersion>1.3.42.1</FileVersion>
<Version>1.3.42.1</Version>
<AssemblyVersion>1.3.43.0</AssemblyVersion>
<FileVersion>1.3.43.0</FileVersion>
<Version>1.3.43.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.ParameterAccessor/Implem.ParameterAccessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.42.1</AssemblyVersion>
<FileVersion>1.3.42.1</FileVersion>
<Version>1.3.42.1</Version>
<AssemblyVersion>1.3.43.0</AssemblyVersion>
<FileVersion>1.3.43.0</FileVersion>
<Version>1.3.43.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public ContentResultInheritance GetByApi(Context context, bool internalRequest =
{
SetSite(
context: context,
initSiteSettings: true);
initSiteSettings: true,
setSiteIntegration: true);
if (!Site.WithinApiLimits(context: context))
{
return ApiResults.Get(ApiResponses.OverLimitApi(
Expand All @@ -141,7 +142,10 @@ public ContentResultInheritance GetByApi(Context context, bool internalRequest =

public BaseItemModel[] GetByServerScript(Context context)
{
SetSite(context: context);
SetSite(
context: context,
initSiteSettings: true,
setSiteIntegration: true);
if (!Site.WithinApiLimits(context: context))
{
return null;
Expand Down Expand Up @@ -466,28 +470,6 @@ public ContentResultInheritance UpdateByApi(Context context, string referenceTyp
}
}

public ContentResultInheritance UpsertByApi(Context context, string referenceType = null)
{
SetSite(
context: context,
initSiteSettings: true);
if (!Site.WithinApiLimits(context: context))
{
return ApiResults.Get(ApiResponses.OverLimitApi(
context: context,
siteId: Site.SiteId,
limitPerSite: context.ContractSettings.ApiLimit()));
}
switch (referenceType ?? Site.ReferenceType)
{

<!--Model_UpsertByApiCases-->

default:
return ApiResults.Get(ApiResponses.NotFound(context: context));
}
}

public bool UpdateByServerScript(Context context, object model)
{
SetSite(context: context);
Expand Down Expand Up @@ -528,6 +510,45 @@ public bool UpdateByServerScript(Context context, object model)
}
}

public ContentResultInheritance UpsertByApi(Context context, string referenceType = null)
{
SetSite(
context: context,
initSiteSettings: true);
if (!Site.WithinApiLimits(context: context))
{
return ApiResults.Get(ApiResponses.OverLimitApi(
context: context,
siteId: Site.SiteId,
limitPerSite: context.ContractSettings.ApiLimit()));
}
switch (referenceType ?? Site.ReferenceType)
{

<!--Model_UpsertByApiCases-->

default:
return ApiResults.Get(ApiResponses.NotFound(context: context));
}
}

public bool UpsertByServerScript(Context context, object model)
{
SetSite(context: context);
if (!Site.WithinApiLimits(context: context))
{
return false;
}
switch (Site.ReferenceType)
{

<!--Model_UpsertByServerScriptCases-->

default:
return false;
}
}

public string DeleteComment(Context context)
{
SetSite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
var #modelName#Ss = Site.#TableName#SiteSettings(
context: context,
referenceId: ReferenceId);
if(model is string #modelName#RequestString)
if (model is string #modelName#RequestString)
{
context.ApiRequestBody = #modelName#RequestString;
}
else if(model is ServerScriptModelApiModel #modelName#ApiModel)
else if (model is ServerScriptModelApiModel #modelName#ApiModel)
{
context.ApiRequestBody = #modelName#ApiModel.ToJsonString(
context: context,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Id": "Model_UpsertByServerScriptCases",
"RepeatType": "Table",
"Indent": "4",
"Separator": "\\r\\n",
"ItemOnly": "1",
"Exclude": "Sites,Wikis"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
case "#TableName#":
var #modelName#Ss = Site.#TableName#SiteSettings(
context: context,
referenceId: ReferenceId);
if (model is string #modelName#RequestString)
{
context.ApiRequestBody = #modelName#RequestString;
}
else if (model is ServerScriptModelApiModel #modelName#ApiModel)
{
context.ApiRequestBody = #modelName#ApiModel.ToJsonString(
context: context,
ss: #modelName#Ss);
}
else
{
return false;
}
return #ModelName#Utilities.UpsertByServerScript(
context: context,
ss: #modelName#Ss,
previousTitle: Title,
model: model);
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace Implem.Pleasanter.Models
<!--Model_Utilities_BulkProcess-->
<!--Model_Utilities_UpdateByApi-->
<!--Model_Utilities_UpsertByApi-->
<!--Model_Utilities_UpsertByServerScript-->
<!--Model_Utilities_Copy-->
<!--Model_Utilities_Copy_Sites-->
<!--Model_Utilities_Move-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Id": "Model_Utilities_UpsertByServerScript",
"Indent": "2",
"ItemOnly": "1",
"Include": "Results,Issues"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
public static bool UpsertByServerScript(
Context context,
SiteSettings ss,
string previousTitle,
object model)
{
var api = context.RequestDataString.Deserialize<Api>();
var #modelName#ApiModel = context.RequestDataString.Deserialize<#ModelName#ApiModel>();
if (api?.Keys?.Any() != true || #modelName#ApiModel == null)
{
context.InvalidJsonData = !context.RequestDataString.IsNullOrEmpty();
return false;
}
api.View = api.View ?? new View();
api.Keys.ForEach(columnName =>
{
var objectValue = #modelName#ApiModel.ObjectValue(columnName: columnName);
if (objectValue != null)
{
api.View.AddColumnFilterHash(
context: context,
ss: ss,
column: ss.GetColumn(
context: context,
columnName: columnName),
objectValue: objectValue);
api.View.AddColumnFilterSearchTypes(
columnName: columnName,
searchType: Column.SearchTypes.ExactMatch);
}
});
var #modelName#Model = new #ModelName#Model(
context: context,
ss: ss,
#modelName#Id: 0,
view: api.View,
#modelName#ApiModel: #modelName#ApiModel);
switch (#modelName#Model.AccessStatus)
{
case Databases.AccessStatuses.Selected:
break;
case Databases.AccessStatuses.NotFound:
return CreateByServerScript(
context: context,
ss: ss,
model: model);
default:
return false;
}
var invalid = #ModelName#Validators.OnUpdating(
context: context,
ss: ss,
#modelName#Model: #modelName#Model,
api: true,
serverScript: true);
switch (invalid.Type)
{
case Error.Types.None:
break;
default:
return false;
}
#modelName#Model.SiteId = ss.SiteId;
#modelName#Model.SetTitle(
context: context,
ss: ss);
#modelName#Model.VerUp = Versions.MustVerUp(
context: context,
ss: ss,
baseModel: #modelName#Model);
var errorData = #modelName#Model.Update(
context: context,
ss: ss,
notice: true,
previousTitle: previousTitle);
switch (errorData.Type)
{
case Error.Types.None:
if (model is Libraries.ServerScripts.ServerScriptModelApiModel serverScriptModelApiModel)
{
if (serverScriptModelApiModel.Model is #ModelName#Model data)
{
data.SetByModel(#modelName#Model: #modelName#Model);
}
}
return true;
case Error.Types.Duplicated:
return false;
default:
return false;
}
}
Loading

0 comments on commit 6b341fb

Please sign in to comment.