-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Privacy Concern Event wrapper #1310
Draft
nahidfgh
wants to merge
6
commits into
main
Choose a base branch
from
PG-swift-wrapper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b0eead5
Added privacy concern provider
nahidfgh 326da18
Address comments
nahidfgh 9cd4b5c
remove privacy concern event
nahidfgh 16098fe
revert version
nahidfgh c12b796
remove import
nahidfgh bb5b255
swift wrapper added
nahidfgh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/*! | ||
@brief Represents a metadata provider for privacy concern events. | ||
*/ | ||
@interface ODWPrivacyConcernMetadataProvider : NSObject | ||
|
||
/*! | ||
@brief Get the database name. | ||
@param record The record for which to retrieve the database name. | ||
@return A string representing the database name. | ||
*/ | ||
- (NSString *)getDatabaseNameForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the server name. | ||
@param record The record for which to retrieve the server name. | ||
@return A string representing the server name. | ||
*/ | ||
- (NSString *)getServerNameForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the event locator name. | ||
@param record The record for which to retrieve the event locator name. | ||
@return A string representing the event locator name. | ||
*/ | ||
- (NSString *)getEventLocatorNameForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the event locator value. | ||
@param record The record for which to retrieve the event locator value. | ||
@return A string representing the event locator value. | ||
*/ | ||
- (NSString *)getEventLocatorValueForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the override for the privacy guard event time. | ||
@param record The record for which to retrieve the event time override. | ||
@return An integer representing the event time override. | ||
*/ | ||
- (int64_t)getPrivacyGuardEventTimeOverrideForRecord:(id)record; | ||
|
||
/*! | ||
@brief Check if the record should be ignored. | ||
@param record The record to check. | ||
@return A boolean indicating whether the record should be ignored. | ||
*/ | ||
- (BOOL)getShouldIgnoreOverrideForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the associated tenant. | ||
@param record The record for which to retrieve the associated tenant. | ||
@return A string representing the associated tenant. | ||
*/ | ||
- (NSString *)getAssociatedTenantForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the environment. | ||
@param record The record for which to retrieve the environment. | ||
@return A string representing the environment. | ||
*/ | ||
- (NSString *)getEnvironmentForRecord:(id)record; | ||
|
||
/*! | ||
@brief Get the metadata. | ||
@param record The record for which to retrieve the metadata. | ||
@return A string representing the metadata. | ||
*/ | ||
- (NSString *)getMetadataForRecord:(id)record; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ODWPrivacyConcernMetadataProvider.h" | ||
|
||
/*! | ||
@brief Represents a metadata provider for privacy concern events. | ||
*/ | ||
@implementation ODWPrivacyConcernMetadataProvider : NSObject | ||
|
||
- (NSString *)getDatabaseNameForRecord:(id)record { | ||
return @""; // Default implementation | ||
} | ||
|
||
- (NSString *)getServerNameForRecord:(id)record { | ||
return @""; // Default implementation | ||
} | ||
|
||
- (NSString *)getEventLocatorNameForRecord:(id)record { | ||
return @"BaseType"; // Default implementation | ||
} | ||
|
||
- (NSString *)getEventLocatorValueForRecord:(id)record { | ||
return [record baseType]; // Example assuming `record` has a `baseType` property | ||
} | ||
|
||
- (int64_t)getPrivacyGuardEventTimeOverrideForRecord:(id)record { | ||
return [record time]; // Example assuming `record` has a `time` property | ||
} | ||
|
||
- (BOOL)getShouldIgnoreOverrideForRecord:(id)record { | ||
return NO; // Default implementation | ||
} | ||
|
||
- (NSString *)getAssociatedTenantForRecord:(id)record { | ||
return [record iKey]; // Example assuming `record` has an `iKey` property | ||
} | ||
|
||
- (NSString *)getEnvironmentForRecord:(id)record { | ||
return @""; // Default implementation | ||
} | ||
|
||
- (NSString *)getMetadataForRecord:(id)record { | ||
return @""; // Default implementation | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
wrappers/swift/Sources/OneDSSwift/PrivacyConcernMetadataProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import ObjCModule | ||
|
||
/// Wrapper over ODWPrivacyConcernMetadataProvider class. | ||
public final class PrivacyConcernMetadataProvider { | ||
|
||
/// ObjC variable which is wrapped by Swift. | ||
var odwPrivacyConcernMetadataProvider: ODWPrivacyConcernMetadataProvider | ||
|
||
/// Constructor initialized with ObjC wrapped object. | ||
init(odwPrivacyConcernMetadataProvider: ODWPrivacyConcernMetadataProvider) { | ||
self.odwPrivacyConcernMetadataProvider = odwPrivacyConcernMetadataProvider | ||
} | ||
|
||
/// Default constructor. | ||
public init() { | ||
odwPrivacyConcernMetadataProvider = ODWPrivacyConcernMetadataProvider() | ||
} | ||
|
||
/// Get the database name for the provided record. | ||
public func getDatabaseName(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getDatabaseNameForRecord(record) | ||
} | ||
|
||
/// Get the server name for the provided record. | ||
public func getServerName(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getServerNameForRecord(record) | ||
} | ||
|
||
/// Get the event locator name for the provided record. | ||
public func getEventLocatorName(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getEventLocatorNameForRecord(record) | ||
} | ||
|
||
/// Get the event locator value for the provided record. | ||
public func getEventLocatorValue(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getEventLocatorValueForRecord(record) | ||
} | ||
|
||
/// Get the override for the privacy guard event time for the provided record. | ||
public func getPrivacyGuardEventTimeOverride(for record: Any) -> Int64 { | ||
return odwPrivacyConcernMetadataProvider.getPrivacyGuardEventTimeOverrideForRecord(record) | ||
} | ||
|
||
/// Check if the record should be ignored. | ||
public func getShouldIgnoreOverride(for record: Any) -> Bool { | ||
return odwPrivacyConcernMetadataProvider.getShouldIgnoreOverrideForRecord(record) | ||
} | ||
|
||
/// Get the associated tenant for the provided record. | ||
public func getAssociatedTenant(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getAssociatedTenantForRecord(record) | ||
} | ||
|
||
/// Get the environment for the provided record. | ||
public func getEnvironment(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getEnvironmentForRecord(record) | ||
} | ||
|
||
/// Get the metadata for the provided record. | ||
public func getMetadata(for record: Any) -> String { | ||
return odwPrivacyConcernMetadataProvider.getMetadataForRecord(record) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config.metadataProvider
should beconfig.MetadataProvider
defined here. However, current implementation does not assign metadata provider to underlying data structure in PG C++. This is because in PG C++, Metadata provider is defined asconst std::shared_ptr<PrivacyConcernMetadataProvider> MetadataProvider;
, so you will need to convert yourODWPrivacyConcernMetadataProvider
to this type. Unfortunately, there is no direct conversion between Obj-C and C++ class implementations. One way I found to achieve this is to use composition. In this link, it talks about how to do this.I think this is what you need
`
// h file
@interface ODWPrivacyConcernMetadataProvider: NSObject
{
@public
PrivacyConcernMetadataProvider *cppObject;
}
@EnD
// mm file
@implementation MyCPPWrapper
{
if (cppObject)
cppObject->GetDatabaseName(id);
}
@EnD
`