Automated replacement of the scm part properties of a pom - version-control

At the moment we're going to migrating all of our cvs projects to git.
Our custom script is using the git converter and everything is fine.
Now i would like to incorporate the automated replacement of the scm part
properties with the new values.
Is there a plugin similar to org.codehaus.mojo:versions-maven-plugin but appling to the scm part?

No, but it would be a trivial plugin to implement.
Just define search and replace patterns:
/**
* #parameter expression="${project}"
* #readonly
*/
private MavenProject project;
/**
* #parameter expression="${searchPattern}"
* #required
*/
private String searchPattern;
/**
* #parameter expression="${replacePattern}"
* #required
*/
private String replacePattern;
/**
* #component
*/
private ModelWriter modelWriter;
public void execute(){
final Model model = project.getModel();
model.getScm().setConnection(
model.getScm()
.getConnection()
.replaceFirst(searchPattern, replacePattern));
// do the same for scm.getDeveloperConnection()
modelWriter.write(
new File(project.getBasedir(),"pom.xml"),
Collections.<String,Object>emptyMap(), model);
}

No there is no plugin for this kind of purpose. (May be someone else knows one?)

Related

Extend repository in TYPO3 9.5 LTS / Extbase

I'm trying to extend this IndexRepository to add my own method for a special search.
In the controller I inject my own IndexRepository with:
use Webian\Iancalendar\Domain\Repository\IndexRepository;
/**
* Inject index repository.
*
* #param IndexRepository $indexRepository
*/
public function injectIndexRepository(IndexRepository $indexRepository)
{
$this->indexRepository = $indexRepository;
}
What I did is working but I get this warning:
PHP Warning
Core: Error handler (BE): PHP Warning: Declaration of Webian\Iancalendar\Controller\
BackendController::injectIndexRepository(Webian\Iancalendar\Domain\Repository\IndexRepository $indexRepository)
should be compatible with HDNET\Calendarize\Controller\
AbstractController::injectIndexRepository(HDNET\Calendarize\Domain\Repository\IndexRepository $indexRepository)
in /typo3conf/ext/iancalendar/Classes/Controller/BackendController.php line 42
That's because I'm using my own Webian\Iancalendar\Domain\Repository\IndexRepository that extends HDNET\Calendarize\Domain\Repository\IndexRepository. If I use the original one the warning doesn't appear but obviously my own method is not called.
How can I avoid that warning?
You should either not extend HDNET\Calendarize\Controller\AbstractController but the default AbstractController of Extbase, then you will need to implement all required logic yourself.
Or you just use a different name for your injection method:
use HDNET\Calendarize\Controller\AbstractController;
use MyNamespace\MyExtension\Domain\Repository\IndexRepository;
class MyController extends AbstractController
{
...
/**
* The index repository.
*
* #var IndexRepository
*/
protected $myIndexRepository;
/**
* Inject index repository.
*
* #param IndexRepository $myIndexRepository
*/
public function injectMyIndexRepository(IndexRepository $myIndexRepository)
{
$this->myIndexRepository = $myIndexRepository;
}
...
class IndexRepository extends \HDNET\Calendarize\Domain\Repository\IndexRepository
{
...
// My method that extends \HDNET\Calendarize\Domain\Repository\IndexRepository functionalities
public function findByStartDate(DateTime $startDate = null, DateTime $endDate = null)
{
...
The method name does not really matter, only that it starts with inject and has a type hint indicating the dependency to inject.

TYPO3 delete reference files with object

I have TYPO3 version 7.6.18. Tell me please how make auto deleting all reference files when I repository->remove($object) ?
You can add #cascade remove to your domain model property's docblock to have it removed on removal of the entity.
Here's a snippet of the blog_example extension used in Extbase's functional tests:
/**
* The posts of this blog
*
* #var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\ExtbaseTeam\BlogExample\Domain\Model\Post>
* #lazy
* #cascade remove
*/
protected $posts = null;

Extend tx_news with 1 field without extension_builder

I try to extend the tx_news extension with the field imageright.
For that I found this tutorial: https://docs.typo3.org/typo3cms/extensions/news/2.2.1/Main/Tutorial/ExtendingNews/Index.html
The first step is to use extension_builder to add the field. As I already have a extension in where I want to implement the extension I do not want to use the extension_builder (also I tried it with a new extension and extend the news-model did not work - I have no clue how to do it right). However this are the steps I did:
In my extension my_template I added the folders and file: Classes/Domain/Model/News.php:
class MyTemplate_Domain_Model_News extends Tx_News_Domain_Model_News {
/**
* #var bool
*/
protected $imageright;
/**
* Returns the imageright
*
* #return bool $imageright
*/
public function getImageright() {
return $this->imageright;
}
/**
* Sets the sort
*
* #param bool $imageright
* #return void
*/
public function setImageright($imageright)
{
$this->imageright = $imageright;
}
}
?>
/Ressources/Private/extend-news.txt:
Domain/Model/News
Created the field imageright as tinyint in the table tx_news_domain_model_news (and added it to the SQL file)
I knew I have to create a TCA file in /Configuration/TCA/, but I have no clue how this should look like or what name it needs to have. I think this is the last step I need to make this working.
Also note the extension my_template was just a template, so before my changes there where no Classes and no TCA files.
Solution is to use this tutorial: http://www.lukasjakob.com/extend-a-typo3-extbase-model-with-custom-field/

MongoException: zero-length keys are not allowed, did you use $ with double quotes?

I'm using symfony2 and mongodb, until today, everything is OK, but I create a new document, and suddenly, appears this error :
"MongoException: zero-length keys are not allowed, did you use $ with double quotes?"
$dm = $this->get('doctrine.odm.mongodb.document_manager');
$_repo = $dm->getRepository('CantaoCustomerBundle:CustomerTags');
$_repo->findOneByCustomer($customer);
The $customer it's OK, the repository is empty, and my document class is like this :
/**
* #MongoDB\ID
**/
private $id;
/**
* #MongoDB\ReferenceOne(targetDocument="Tapronto\Mats\ProductBundle\Document\Tag", cascade={"persist"})
**/
private $tag;
/**
* #MongoDB\ReferenceOne(targetDocument="Tapronto\Mats\CustomerBundle\Document\Customer", cascade={"persist"})
**/
private $customer;
/**
* #MongoDB\Float
**/
private $points;
/**
* #MongoDB\Int
**/
private $viewed;
/**
* #MongoDB\Int
**/
private $brought;
/**
* #MongoDB\Int
**/
private $favorited;
/**
* #MongoDB\Date
* #Gedmo\Timestampable(on="create")
**/
private $createdAt;
/**
* #MongoDB\Date
* #Gedmo\Timestampable(on="update")
**/
private $updatedAt;
Can anyone help me, have some idea, I tried everything and nothing seems to work
I just fixed this by using the referenced object's ID instead of the reference object itself as my search term.
$_repo->findOneByCustomer($customer->getId());
EDIT:
That isn't throwing the exception but it isn't actually returning anything either. I tried using new MongoId($id) as was suggested a few places (Doctrine MongoDB find by id), but that didn't work either. Finally, I found something in the full query builder that searches by references (note: this uses the object instead of the object's ID).
$dm->createQueryBuilder()->find('CantaoCustomerBundle:CustomerTags')
->field('customer')->references($customer)
->getQuery()->execute();
I feel like this should be done more simply (like you did originally), but this fix is working for me.
It could be that you're trying to persist an object private attribute.
If that's not the case a good way to debug is to shut off the zero-length key check so that you can actually debug by checking what it's being written into mongo.
zero-length keys are not allowed, did you use $ with double quotes?
Code: 1
You tried to save "" as a key. You generally should not do this. "" can mess up subobject access and is used by MongoDB internally. However, if you really want, you can set mongo.allow_empty_keys to true in your php.ini file to override this sanity check. If you override this, it is highly recommended that you set error checking to strict to avoid string interpolation errors.
http://php.net/manual/en/mongo.configuration.php#ini.mongo.allow-empty-keys

How can I protect my methods bodies (not the attached JavaDoc and Signature) using Acceleo code-generator

I use Acceleo in order to generate code with a model I have made. I managed to protect my methods in order to protect them usinig "#generated NOT" in case I need to regenerate my code with Acceleo. The problem is that adding #generated NOT protect all the method content, that is to say the body, the signature and JavaDocs.
The thing is that I only need to keep the method body, or at least the method body and its signature, but I need the doc to be updated. How can I do this ?
Just for information here is an example of a potential generated class :
/*
* #generated
*/
public class ActeurRefEntrepriseServicesImpl implements ActeurRefEntrepriseServices {
#Autowired
HelloWorldService helloWorldService;
/**
* Service which say hello
*
* #param name
* user name
* #return print Hello username
*
* #generated NOT
*/
#Override
public void sayHello(final String name) {
helloWorldService.print(name);
}
}
Baptiste,
The #generated tags use the standard EMF protection rules : "#generated" means that the body of the block for which it is set will be generated, anything else means no re-generation. If you set something as "#generated" in any of your metamodels' generated code, you will see that there, too, the javadoc is preserved whatever the edits you do.
In short, you cannot tell EMF to re-generate anything other than the code itself.
If you need to have the body protected but not the javadoc, you have to shift from the "#generated" protection to Acceleo's [protected] blocks. i.e, change your template from :
[template generatedMethod(methodName : String)]
/**
* Some doc.
* #param param1
* param documentation.
* #generated
*/
[generateSignature(methodName)/] {
[generateBody()/]
}
[/template]
to something using a protected block :
[template generatedMethod(methodName : String)]
/**
* Some doc.
* #param param1
* param documentation.
*/
[protected (methodName)]
[generateSignature(methodName)/] {
[generateBody()/]
}
[/protected]
[/template]
With this paradigm, anything that is outside of the protected area will be regenerated, everything else will remain untouched by a regeneration.
See also the full documentation available from the Acceleo website.
If you absolutely need to use the "#generated" protection method for your model, you will need to tamper with the JMerger API from EMF and alter the launcher Acceleo generated for you in order to use your own merging strategy (see the getGenerationStrategy method from that launcher). Note that this is by no means an easy task.