I'm so sorry about what you have had to go through.
Just for future reference, some dogs do well as farm dogs, some don't. While any breed CAN be acclimatized to being around livestock, I have to say in all honesty, I have only ever known one Rottie that was good around livestock, and he was raised IN the goat barn from a 5 week old pup.
I would never recommend hitting/kicking your dog for going after the pig, that only makes a further bad association with the animal. I'm very sorry you got bit.
There are a lot of breeds that have been BRED to be farm dogs, and do exactly what you are looking for in a dog. Stick with those in the future - Border Collies, Aussies, even some bloodlines of Rough Collies (like mine!) get them neutered as soon as they are old enough to do so, socialise them with the livestock early on and teach them their boundaries while they are young. Get them in obedience training by 10 weeks of age, and you will have a great farm dog, and a great working companion. Your current dog is neither, he's a pet, so understand that about him, and treat him accordingly. Keep him away from your livestock, love him and give him plenty of one on one time, but don't take him into the barn.
I don't believe he's beyond learning how to act appropriately around the animals, but you would need to invest in a trainer who knows what they are doing to acclimatize him. I don't think from the sounds of it this is something you would or should tackle on your own. Shock collars can be very valuable tools in this kind of situation, but only in the hands of someone who REALLY knows how to use them properly.
Good luck and I hope once he is no longer kept in the yard with Sexy (great piggy name, BTW) he will be a beloved family pet.