Need CoreData model design advice - core-data

I have three types of images - regular, favorite and trashed. So I've created three entities in CoreData model designer. I could create inheritance, but regular images are cleared all the time, and if 2 other types inherit from it, they are cleared too, and this is invalid behavior for me (obviously). At the same time these models are very similar. What I want is that they have common parent which contains methods for downloading and saving them in cache. How can I achive this in CoreData?

I've figured it out. You can create any inheritance hierarchy with your classes (root object must inherit NSManagedObject). Inheritance of entities is another topic here. Just set entity name to desired class name and this entity will store data for that class. Simple and smart behavior! F.e. you have class A with properties a1 and a2 and method foo. And class B with b1 and b2. You want to store them in different tables, but want to B inherit A to have a1 and a2 and be able to call foo. You create class A : NSManagedObject with mentioned properties and method, then B : A with dynamic properties b1 and b2. That's all your code. Now create 2 models: A with a1 and a2 attributes and B with a1, a2, b1 and b2 attributes. NO entity inheritance B from A needed here. If you will not add a1 and a2 attributes to B entity, these properties will be visible in your code, but raise runtime "not recognized selector" exception. Hope this will help some newbie in CoreData.

Related

How to modify dynamic complex data type fields in azure data factory data flow

This bounty has ended. Answers to this question are eligible for a +400 reputation bounty. Bounty grace period ends in 22 hours.
kevzettler is looking for a more detailed answer to this question.
I have a complex data type (fraudData) that undesirably has hyphen characters in the field names I need to remove or change the hypens to some other character.
The input schema of the complex object looks like:
I have tried using the "Select" and "Derive Column" data flow functions and adding a custom mapping. It seems both functions have the same mapping interface. My current attempt with Select is:
This gets me close to the desired results. I can use the replace expression to convert hypens to underscores.
The problem here is that this mapping creates new root level columns outside of the fraudData structure. I would like to preserve the hierarchy of the fraudData structure and modify the column names in place.
If I am unable to modify the fraudData in place. Is there any way I can take the new columns and merge them into another complex data type?
Update:. I do not know the fields of the complex data type in advance. This is a schema drift problem. This is why I have tried using the pattern matching solution. I will not be able to hardcode out kown sub-column names.
You can rename the sub-columns of complex data type using derived column transformation and convert them as a complex data type again. I tried this with sample data and below is the approach.
Sample complex data type column with two sub fields are taken as in below image.
img:1 source data preview
In Derived column transformation, For the column fraudData, expression is given as
#(fraudData_1_chn=fraudData.{fraudData-1-chn},
fraudData_2_chn=fraudData.{fraudData-2-chn})
img:2 Derived column settings
This expression renames the subfields and nests them under the parent column fraudData.
img:3 Transformed data- Fields are renamed.
Update: To rename sub columns dynamically
You can use below expression to rename all the fields under the root column fraudData.
#(each(fraudData, match(true()), replace($$,'-','_') = $$))
This will replace fields which has - with _.
You can also use pattern match in the expression.
#(each(fraudData, patternMatch(`fraudData-.+` ), replace($$,'-','_') = $$))
This expression will take fields with pattern fraudData-.+ and replace - with _ in those fields only.
Reference:
Microsoft document on script for hierarchical definition in data flow.
Microsoft document on building schemas using derived column transformation .

VBA Scenario Testing in a financial model

So I'm new to VBA and trying to automate my financial models. I've got this large complex stock valuation model on excel that reads either string bear, bull, or base from a single cell that has a dropdown that has the options of bear, bull, or base. The model will use different inputs depending on if the user chooses the strings bear, bull, or base, and the model will output different values of the stock respectively. In a separate sheet, I'm trying to display, in 3 separate cells, the output of the model (the value of the stock) in the bear, bull, and base case respectively. I could just make 3 models; a bear, bull, and base case, but I thought that might be too bulky, and I just want 1 variable model, instead of 3 fixed models. I'm wondering if VBA allows for a "scenario" type of ability in which it sets a specific cell to a hypothetical value and then takes the value of another cell, without actually modifying my model.
I think I understand what you want -- but it is still unclear. Perhaps provide an example?
One way I'd do it would be to have a fourth dynamic model. This extra model is based on the hypothetical scenarios (e.g. another column for Bear/Bull/Base for each stock -- we can call this extra column BBB2, and the original one with drop down menus for the user BBB1). The fourth model is based only on data from BBB2.
By default when the sheet is opened, BBB2 = BBB1. When a user changes BBB1, BBB2 gets updated. Then, I'd add a function to change everything in BBB2 to bull or base or bear. From there you could manually change a few stocks and see the results in the fourth model.

Access object numbers in examples

If I have just one sig A and want to chain multiple instances of it (for example by a successor relation), Alloy will number them (A1, A2, A3 ,...) randomly.
Is there a way to tell it, that I want these in ascending order ?
Or that A3 has to come after A1, but A2 before A4 or similar constraints.
If your goal is to impose a total order on A then I would suggest using the util/ordering library:
open util/ordering[A]
If you use this library then the Analyzer will do its best to keep the A atoms in ascending order (according to the next relation that is declared in the library, meaning that A$1.next will be A$2 and so on). Also, analysis will be more efficient due to improved symmetry breaking. However, you need to be aware that signature A will become fully saturated, in the sense that a scope of 5 A will be the same as exactly 5 A.
There is no way of connecting names of sig instances to whatever relation you defined in your model (be it with your "chaining relation" or util/ordering library), in the general case. (Essentially, this is up to Alloy's solver which might instantiate fresh names unpredictably.)
One alternative, that could perhaps work in your case, might be to declare multiple sigs, for example:
one sig A1, A2, A3, ... extends A {}
with a "chaining relation":
succ = A1 -> A2 + A2 -> A3 + ...
Now, since the ordering is fixed explicitly on signatures with names, that are ordered, the models found by Alloy will indeed satisfy your desired property.

SharePoint workflow condition on multiple choice column

I try to have a condition on a multiple choice column.
With single choice it is working easyly but I could not find a method
to do it with a multiple choice column.
For instance, the column named "Choices" has the possible values: Car, Bike, Bus, Plane
So I want a condition to check for the values that were selected (in pseudocode)
IF Choices contains "Car" then ....
IF Choices contains "Bike" then ....
IF Choices contains "Bus" then ....
IF Choices contains "Plane" then ....
But in the designer when I tried to implement such a condition, im not able to write this structure.
Someone told me to convert the values from the multiple chpice column to a calculated column to work with it, but isnt there a more comfortable solution?
I already asked it in the the social TechNet with the described solution:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/41faa48a-85e9-4526-b416-05cf3eeb2e0b/sharepoint-designer-workflow-condition-on-multiple-choice-field?forum=sharepointcustomization
But I dont believe I am the only one who ever needed such a condition.
UPDATE: Since it appears to be the only solution I am copying the value of the multiple choice column as choice value to a workflow variable of type string. Then the string is set as value for a normal text column. Now I can have the condition
IF value of clolumn contains "Car" then....

What difference between reference objects and value objects in UML?

I don't understand description in Martin Fowler's "UML Distilled" book.
Think of a reference object as being a specific instance with a "life" of its own, that several people may be interested in. For example an Employee, or an Order. If I go and get Employee number 83 and ask for some of its attributes and you do the same thing we would expect to get the same answer, if I change the employee's phone number then you see that change:
we are both referring to the same object
A value object is something that it makes sense to copy around "by value". An example Fowler gives is a Date. What's the date of that order? What's the birthday of that employee? We have a copy of the date, by implication it would be silly to change it. There's no expectation that this value object "knows" it's an employee's birthday - it's just a useful value to pass around.
A reference is an address (pointer) to where the value of the object resides. A value is the actual value the binary representation. If you assign a value you are making a copy of the value into the new variable. If you assign a reference you are just passing the address of where the value is saved.

Resources