Thursday, November 15, 2012

Creating CodeCollaborator reviews using command line

Some months ago, I started using CodeCollaborator to create code reviews and ensure our developments have the desired quality.

We are at the end of our development sprint, so I tried to create some code reviews using the CodeCollaborator GUI with no success. Aparently, one of the latest Java VM updates "broke" my client; actually because we are using an old version of CodeCollaborator client (v 4) which cannot work under the latest versions of Java.

So if you run into the same problem, or just want to create your reviews using the command line follow the next steps described below. (Disclaimer: this was only tested on Windows and using SVN as source control, since that's our current development environment),


  1. Open the command line prompt
  2. Go to your working copy folder, some thing like this
    cd "C:\Folder\Folder\MyProjectWorkingCopyRoot"
  3. Login into your CodeCollaboration Server
    ccolab login  [ServerUrl] [UserName] [Password]
    
    You will get something like this
    Connecting to Code Collaborator Server https://[your.server.url]/
    Connected as: [Your name and username]
    
    New configuration worked - saving configuration settings
    Configuration key 'url' saved.
    Configuration key 'user' saved.
    Configuration key 'password' saved.
    Configuration key 'server-proxy-host' cleared.
    Configuration key 'server-proxy-port' cleared.
    
  4. You can upload specific files, changelists, etc. In my case I needed upload all the changes made on an specific revision, so I needed to pass a SVN diff as a parameter
    ccollab addsvndiffs new -r 27183:27190
    If you look I added the parameter "new" wich means I'm creating a new review (and will be named "Untitled Review"); you can also pass the review-id if you want to add files to an existing review.
With this, you can easily add files when creating or updating any CodeCollaborator review. For more information go to the CodeCollaboration command line reference 

Tuesday, November 6, 2012

Overcome to Windows Azure free trial cancellation by adding a new plan

I decided to try Windows Azure more than 3 months ago, most likely because of it's free 90-day offer. I can tell that I'm amazed on all the posibilies you have for free (Websites, Virtual machines, Mobile Services, etc.).

So then, I decided I wanted to continue with the service after my trial period ended by "acquiring" a Pay-As-You-Go plan (that as the name says, you pay only what you use only if you use it, so at the time of my purchase my total was $0.00).

Since I was swamped with many things at job, I didn't payed much attention on the warning e-mails saying that my account was about to expire. As it might be expected, my account was cancelled 2 weeks ago. Last week I was trying to upgrade my account, so I signed up on the Pay-As-You-Go plan but after several tries and wating days, I still wasn't able to use it to create new websites with it.



So this is the process that you need to follow in order to be able to use your new plan in your account:


  1. Acquire a new plan (Pay-As-You-Go, 6 or 12 month, etc.)
  2. Go to Preview Features page and select the feature that you want to enable for your new plan, in my case I wanted to be able to create websites again
  3. Click on "Try it now"
  4. Select the plan you want to associate (your new plan). In this case I'm showing an example with Media Services because I already joined to the Websites preview

After completing this, you will see a label on the screen saying that the feature is active



and you will be able to create websites (or any of the preview features that you selected) under your new plan


Sadly, my previous websites remain cancelled and it doesn't seem to be possible to associate them with my new plan, or at least I couldn't find a way to edit them on the manage portal.

So, if possible try to avoid your account cancellation, but if that already happened, this post might help you if your plan is not shown on some items on your account.

Saturday, November 3, 2012

Solution to: "The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable"

The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.

Problem description


The error quoted above happened to me after I started using AutoMapper on my WCF service for updating my entities. Previously, I had a "manual map" to assing the properties that I received on my data contract to the entity that I got on my context and update it. When we decided to implement AutoMapper on our project, my mapping code started like this:


Mapper.CreateMap<MyDataContract, MyEntity>.IgnoreAllNonExisting();


Since all my properties were named the same on both classes, everything seemed to be easy peasy.

But sadly, I started gotting the error message
The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.
This message was driving me crazy, because of the text I was thinking that I was making something wrong with the FK relationships on the Database, or in someway the field was being passed null without being null on the contract, or somebody changed the table in someway (yeah sure, blame others :-P). After some deep look on the code (including debugging line by line all the updating process) I found the error.

Since I'm copying the modified values (from DataContract to Entity) when mapping, I'm passing all the values from one instance to the other. This sounds OK, right? I mean, I want all my changes to be persisted on the database.

Well, is not that easy. Since my contract comes from a web application, when saving there I don't have all the navigation properties. When this is the case and I just map all, I'm also mapping and overwriting the values of this navigation properties, that in this case are null on my DataContract. This makes the Entity to update the ForeignKey Columns that belong to that navigation property to be null too. That is why the error says that you're sending null values, because actually you are.

Solution

Since the problem is that we're mapping null navigation properties, and we actually don't need them to be updated on the Entity since they didn't changed on the Contract, we need to ignore them on the mapping definition:

ForMember(dest => dest.RefundType, opt => opt.Ignore())


So my code ended up like this

Mapper.CreateMap<MyDataContract, MyEntity>
ForMember(dest => dest.NavigationProperty1, opt => opt.Ignore())
ForMember(dest => dest.NavigationProperty2, opt => opt.Ignore())
.IgnoreAllNonExisting();


And voilĂ ! the problem is solved.

 

Copyright @ 2013 A learning journey.